Pin input and Pull-up

Post here first, or if you can't find a relevant section!
Post Reply
settler
Posts: 2
Joined: Sat Feb 06, 2021 11:26 am

Pin input and Pull-up

Post by settler »

Hello to all,

so I am trying to figure out why this is not working, but I am running out of ideas.
I have a few pins that must be set as input and must have pull up on them.
Here is how I did it, but it doesnt work:

for (i = 0; i < inc; i++) {
pinMode(inpin, INPUT);
digitalWrite(inpin, INPUT_PULLUP); // activate 20k pull-up

I have tried then just with one pin and its the same. I am using Blue pill STM32F103C8.
by stevestrong » Sat Feb 06, 2021 12:17 pm
INPUT_PULLUP is a parameter for pinMode(), not for digitlWrite().

Code: Select all

pinMode(inpin, INPUT_PULLUP);
digitalWrite(inpin, HIGH); // use HIGH or LOW
Go to full post
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Pin input and Pull-up

Post by stevestrong »

INPUT_PULLUP is a parameter for pinMode(), not for digitlWrite().

Code: Select all

pinMode(inpin, INPUT_PULLUP);
digitalWrite(inpin, HIGH); // use HIGH or LOW
Last edited by stevestrong on Sat Feb 06, 2021 12:19 pm, edited 2 times in total.
ag123
Posts: 1657
Joined: Thu Dec 19, 2019 5:30 am
Answers: 25

Re: Pin input and Pull-up

Post by ag123 »

it should be pinMode( pin, INPUT_PULLUP)

i used that successfully here
built in pull up resistor, DHT11, DHT22
viewtopic.php?f=7&t=530
User avatar
fpiSTM
Posts: 1746
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Pin input and Pull-up

Post by fpiSTM »

https://www.arduino.cc/reference/en/lan ... o/pinmode/


Anyway it seems strange to set a pin in input an do a write.... :shock:
settler
Posts: 2
Joined: Sat Feb 06, 2021 11:26 am

Re: Pin input and Pull-up

Post by settler »

Ohh, waw, looks i am really blind :?

Thanks for this, now it works 8-)
Post Reply

Return to “General discussion”