arduino
int timer = 200; //timer variable created
const int buttonPin = 2; //button is on pin two
int buttonState = 0; //button state is off, click turns it off normal state
int thisPin = 3; //start of blinking lights
void setup() {
for (int thisPin = 3; thisPin < 8; thisPin++) {
pinMode(thisPin, OUTPUT); //set leds as output
pinMode(buttonPin, INPUT); // set button as input
}
}
void loop() {
buttonState = digitalRead(buttonPin); //read what the button is doing before loop of leds
if (buttonState == HIGH) { //if button is not pressed run code
for (int thisPin = 3; thisPin < 8; thisPin++) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(timer);
// turn the pin off:
digitalWrite(thisPin, LOW);
}
} else {
// turn LED off:
digitalWrite(thisPin, LOW); //if button is pressed do not run code
}
}