const int ledPin = D0; // the number of the LED pin const int ledPin1 = D6; // the number of the LED pin const int ledPin2 = D7; // the number of the LED pin const int buttonPin = D1; // the number of the pushbutton pin int buttonState = 0; // variable for reading the pushbutton status void setup() { pinMode(buttonPin, INPUT); // Set buttonPin as an input pinMode(ledPin, OUTPUT); // Set ledPin as an output pinMode(ledPin1, OUTPUT); // Set ledPin1 as an output pinMode(ledPin2, OUTPUT); // Set ledPin2 as an output } void loop() { buttonState = digitalRead(buttonPin); // Read the state of the pushbutton if (buttonState == HIGH) { // If the button is pressed for (int i=0; i <= 4; i++) // Repeat the following block 5 times { delay(1000); // Wait for 1 second digitalWrite(ledPin, HIGH); // Turn on the first LED delay(1000); // Wait for 1 second digitalWrite(ledPin1, HIGH); // Turn on the second LED delay(1000); // Wait for 1 second digitalWrite(ledPin2, HIGH); // Turn on the third LED delay(1000); // Wait for 1 second digitalWrite(ledPin, LOW); // Turn off the first LED delay(1000); // Wait for 1 second digitalWrite(ledPin1, LOW); // Turn off the second LED delay(1000); // Wait for 1 second digitalWrite(ledPin2, LOW); // Turn off the third LED } } else { // If the button is not pressed digitalWrite(ledPin, LOW); // Turn off the first LED digitalWrite(ledPin1, LOW); // Turn off the second LED digitalWrite(ledPin2, LOW); // Turn off the third LED } }