// Program to count how many times a push button is pressed. const int pushButton = 2; int count = 0; void setup() { Serial.begin(9600); pinMode(pushButton, OUTPUT); // active HIGH input } void loop() { // wait for button press while (digitalRead(pushButton) == LOW) { // keep looping here as long as the button is NOT pressed delay(10); } // button has been pressed count++; Serial.println(count); // wait for button release while (digitalRead(pushButton) == HIGH) { // keep looping here as long as the button is pressed delay(10); } }