Hardware wise, i have a physical mecanical button can when pressed connects the pin to GND and when unpressed does not connect anything (open circuit)
At runtime, I observe that once the button is pressed, it works as expected. However, when buttun is unpressed (nothing connected to the pin), i observe erratic random values (0 or 1 alternatively). exactly the behavior what i would expect while using INPUT instead of INPUT_PULLUP in pinMode()
While reading the chipkit code manual, it states that not all pins have an internal pullup resistor (depends on boards) and i might have had bad luck by selecting A8:
INPUT
This sets the pin to be a normal floating input. The state of the input can be read using digitalRead(). An input in this mode with no connection or an open circuit will read an undefined value.
INPUT_PULLUP
Like INPUT this sets the pin to be in an input mode. However the internal pullup resistor (when available; not all boards have pullup resistors available on all pins) will be enabled. A pin in this mode with no connection will, when read with digitalRead(), return a HIGH value.
Question
fourchette
Hello,
I am working on a uc32 chipkit board adapting some existing arduino code.
somewhere in the code, i am using
Hardware wise, i have a physical mecanical button can when pressed connects the pin to GND and when unpressed does not connect anything (open circuit)
At runtime, I observe that once the button is pressed, it works as expected. However, when buttun is unpressed (nothing connected to the pin), i observe erratic random values (0 or 1 alternatively). exactly the behavior what i would expect while using INPUT instead of INPUT_PULLUP in pinMode()
While reading the chipkit code manual, it states that not all pins have an internal pullup resistor (depends on boards) and i might have had bad luck by selecting A8:
INPUT This sets the pin to be a normal floating input. The state of the input can be read using digitalRead(). An input in this mode with no connection or an open circuit will read an undefined value. INPUT_PULLUP Like INPUT this sets the pin to be in an input mode. However the internal pullup resistor (when available; not all boards have pullup resistors available on all pins) will be enabled. A pin in this mode with no connection will, when read with digitalRead(), return a HIGH value.
http://chipkit.net/wiki/index.php?title=API:PinMode
my questions
Thanks
fourchette
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.