The setup: 3 buttons/ moment switches that graph (in Processing) how many times any of the buttons have been pressed.
The problem: 2 out of 3 buttons are not incrementing the bar graph on the first tap of the button unless it is tapped twice. Instead, if I tap a button once, the bar graph fluctuates between 0 and 1 when it's supposed to stay at 1 because the button has been tapped once. If I tap the same button again, the fluctuation stops and remains at 2, then increments upon button presses just fine after that.
At first I thought this may be a debouncing issue, but a ripple signal doesn't occur. The fluctuation remains between 0 and 1.
What's going on??? Please help!
int yesButton = 10; //digital input for the yes button
int noButton = 11; //digital input for the no button
int maybeButton = 12; //digital input for the maybe buttonint yesValue = 0; //reading from the yes button
int noValue = 0; //reading from the no button
int maybeValue = 0; //reading from the maybe buttonvoid setup(){
//configure the serial connection
Serial.begin(9600);//configure the digital inputs
pinMode(yesButton, INPUT);
pinMode(noButton, INPUT);
pinMode(maybeButton, INPUT);
}void loop() {
//read the digital sensors:
if (digitalRead(yesButton) == HIGH) {
yesValue = digitalRead(yesButton);
delay(1000);
} else {
yesValue = digitalRead(yesButton);
}if (digitalRead(noButton) == HIGH){
noValue = digitalRead(noButton);
delay(1000);
} else {
noValue = digitalRead(noButton);
}if (digitalRead(maybeButton) == HIGH) {
maybeValue = digitalRead(maybeButton);
delay(1000);
} else {
maybeValue = digitalRead(maybeButton);
}//print the results:
Serial.print(yesValue, DEC);
Serial.print(",");
Serial.print(noValue, DEC);
Serial.print(",");
//print the last sensor value with a prinln()
//so each reading prints on a line by itself:
Serial.println(maybeValue, DEC);
}