#define Blue_Led 12
#define Red_Led 13
#define Button 2
void setup() {
// put your setup code here, to run once:
pinMode(Blue_Led, OUTPUT);
pinMode(Red_Led, OUTPUT);
pinMode(Button, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(Button),control_led,CHANGE);
}
void loop()
{
digitalWrite(Red_Led, HIGH);
delay(1000);
digitalWrite(Red_Led, LOW);
delay(1000);
}
void control_led() {
// put your main code here, to run repeatedly:
int Button_state=digitalRead(Button);
if (Button_state==LOW)
{
digitalWrite(Blue_Led, HIGH);
}
else
{
digitalWrite(Blue_Led, LOW);
}
}