get some button detected as "pressed" at begining for loop()
Hello,
On IND I/O D21G, the buttons are initialised:
void setup() {
  pinMode(buttonEnterPin, INPUT);
  pinMode(buttonUpPin, INPUT);
  pinMode(buttonDownPin, INPUT);
in the loop(), i have quit the same function as in IndustruinoDemoCode_D21G:
ReadButtons()
the log show :
EnterPressed
UpPressed
DownPressed
But i did not push any button !
any idea ?
Thanks in advance !
Arnaud
hi, a few remarks:
- the buttons inputs have a pull-up resistor to HIGH, so pressed is LOW
 - the demo code you refer to triggers a pressed event at the change from LOW to HIGH: when the button is released (not when it is pressed)
 - you can avoid the initial ghost presses by declaring the startup state as HIGH when you define these variables:
	
- int prevBtnUp = 1; //previous state of "Up" button
 - int prevBtnEnt = 1; //previous state of "Enter" button
 - int prevBtnDown = 1; //previous state of "Down" button
 
 
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
| Asked: 6/20/19, 10:40 AM | 
| Seen: 2307 times | 
| Last updated: 6/21/19, 12:02 AM |