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

 

 

 

Arnaud Lismonde
Arnaud Lismonde
14
| 0 0 0
Asked on 6/20/19, 10:40 AM
0
vote
233 Views

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
Tom
Tom
5450
| 0 0 1
Answered on 6/21/19, 12:02 AM
0
vote

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!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

56 follower(s)

Stats

Asked: 6/20/19, 10:40 AM
Seen: 233 times
Last updated: 6/21/19, 12:02 AM