Page 1 of 1

Pin input and Pull-up

Posted: Sat Feb 06, 2021 11:37 am
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.

Re: Pin input and Pull-up

Posted: Sat Feb 06, 2021 12:17 pm
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

Re: Pin input and Pull-up

Posted: Sat Feb 06, 2021 12:18 pm
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

Re: Pin input and Pull-up

Posted: Sat Feb 06, 2021 12:44 pm
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:

Re: Pin input and Pull-up

Posted: Sat Feb 06, 2021 1:05 pm
by settler
Ohh, waw, looks i am really blind :?

Thanks for this, now it works 8-)