const int button = 6;
const int MAX_ROUNDS = 10;
int buttonState = HIGH;
int lastButtonState = HIGH;
int counter = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// let button be an output
pinMode(button, INPUT_PULLUP); // why input pullup??
//not pressed = high
}
void loop() {
// put your main code here, to run repeatedly:
buttonState = digitalRead(button);
if(buttonState == LOW && lastButtonState == HIGH)
{
counter++;
Serial.print("# of presses: ");
Serial.print(counter);
Serial.println();
delay(100); // for button bounce
}
lastButtonState = buttonState;
//if(timesPressed >= MAX_ROUNDS)
{
// end game, winner!
}
}