int led1 = 13;
int led2 = 12;
int led3 = 11;
int led4 = 10;
const byte interruptPin = 2;
volatile byte state = LOW;
const int button = 8; // the pin that the pushbutton is attached to
int buttonPushCounter = 0; // counter for the number of button presses
int ButtonState = 1; // current state of the button
int lastState = 1; // previous state of the button
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(button, INPUT_PULLUP);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), blink, FALLING);
}
// the loop function runs over and over again forever
void loop() {
ButtonState = digitalRead(button);
if (ButtonState && ButtonState != lastState) // button latch, no debounce needed.
on();
lastState = ButtonState;
// delay(2000);
// off();
}
void on(void){
digitalWrite(led1, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led2, HIGH); // turn the LED off by making the voltage LOW
delay(1000);
digitalWrite(led3, HIGH);
delay(1000);
digitalWrite(led4, HIGH);
delay(2000);
off();
}
void blink() {
//state = !state;
// digitalWrite(led1, LOW);
// digitalWrite(led3, LOW);
//off();
digitalWrite(led2, HIGH);
digitalWrite(led4, HIGH);
digitalWrite(led1, HIGH);
digitalWrite(led3, HIGH);
}
void off(void){
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
}