#define FirstPin 6
const int SecondPin = 7;
const int pushbutton = 2;
int buttonstate = 0;
int count = 0;
void setup() {
// initialize the digital pins as outputs.
// Pin 6 and 7 has an LED connected on Arduino boards:
pinMode(FirstPin, OUTPUT);
pinMode(SecondPin, OUTPUT);
pinMode(pushbutton, INPUT);
attachInterrupt(digitalPinToInterrupt(pushbutton), Inter, RISING);
Serial.begin(9600);
}
void loop() {
buttonstate = digitalRead(pushbutton);
Serial.println(count);
if (buttonstate == HIGH){
count = 1;
}
if (count == 1) {
digitalWrite(FirstPin, HIGH); // set the LED 6 on
digitalWrite(SecondPin, LOW); // set the LED 7 off
delay(1000); // wait for a second
digitalWrite(FirstPin, LOW); // set the LED 6 off
digitalWrite(SecondPin, HIGH); // set the LED 7 on
delay(1000); // wait for a second
} else if (count == 0){
digitalWrite(FirstPin, LOW);
digitalWrite(SecondPin, LOW);
}
}
void Inter(){
count = 0;
return;
}