#define LED 7 // define the led pin #define BTN 3 // define the button pin // Variables will change: bool previous_state = 0; // previous state of the button int i = 1; // index delay // the values of delay int delays[3] = {100, 200, 500}; void setup() { // set the led pin like output pinMode(LED, OUTPUT); // set the button pin like input pinMode(BTN, INPUT_PULLUP); } void loop() { // read the pushbutton input pin: bool button_state = digitalRead(BTN); // compare the buttonState to its previous state if (button_state != previous_state) { // if button has pressed, increment the counter if (!button_state) { i++; if (i > 2) i = 0; } } // save the current state as the last state, //for next time through the loop previous_state = button_state; //blink digitalWrite(LED, HIGH); delay(delays[i]); digitalWrite(LED, LOW); delay(delays[i]); }