Delay before Internal Pullup becomes effective
Posted: Tue Jul 24, 2018 9:58 am
Hi,
I am working on an Arduino sketch and I see a weird problem.
This is my code:
There is nothing connected to pin 21, it is an unpopulated header, and so should be being pulled up by the internal pull up, and should have no load on it.
X is being assigned 0.
Y is being assigned 1.
X & Y, should, in theory, be both 1.
If i change the code to:
Then X & Y are both 1, as expected.
My question is, does anyone else see this? I have tried it on two boards with the same result. I have tried it on other pins, with the same result. It seems strange to have to insert a dummy read, or wait 1 millisecond before the pin state is what it should be.
Steven
I am working on an Arduino sketch and I see a weird problem.
This is my code:
Code: Select all
pinMode(21, INPUT_PULLUP);
X = digitalRead(21);
Y = digitalRead(21);
X is being assigned 0.
Y is being assigned 1.
X & Y, should, in theory, be both 1.
If i change the code to:
Code: Select all
pinMode(21, INPUT_PULLUP);
delay(1);
X = digitalRead(21);
Y = digitalRead(21);
My question is, does anyone else see this? I have tried it on two boards with the same result. I have tried it on other pins, with the same result. It seems strange to have to insert a dummy read, or wait 1 millisecond before the pin state is what it should be.
Steven