I am using this code to monitor 5 pushbuttons
I am expecting to see a 'button pressed' message when I press a button. The problem is that unless the button is pressed when the loop reads it, I will not see the button pressed message. Since my teensy is doing several other things (checking 6 potentiometers) , It is missing button presses. How can I remedy this?
Code:
int btnPins[] = {
19,20,21,22,23
};
int btnCount = 5;
void setup() {
for (int thisBtn = 0; thisBtn < btnCount; thisBtn++)
pinMode(btnPins[thisBtn], INPUT);
}
void loop() {
for (int thisBtn = 0; thisBtn < btnCount; thisBtn++)
inputBtn = digitalRead(btnPins[thisBtn]);
Serial.println(inputBtn);
if (inputBtn == HIGH) {
Serial.println("Button is not pressed...");
} else {
Serial.println("Button pressed!!!");
}
delay(250);
}
I am expecting to see a 'button pressed' message when I press a button. The problem is that unless the button is pressed when the loop reads it, I will not see the button pressed message. Since my teensy is doing several other things (checking 6 potentiometers) , It is missing button presses. How can I remedy this?