#define LED 12 // The digital pin to which the led is connected
#define BUTTONPIN 4 // The digital pin to which the button is connected
// Interrupt function that changes the led pin status
void IRAM_ATTR trigger_led()
{
blinkTen();
}
void blinkTen(){
for (int i = 0; i <= 9; i++) {
digitalWrite(LED, HIGH);
delay(300);
digitalWrite(LED, LOW);
delay(300);
Serial.print("i : ");
Serial.println(i);
}
}
void on(){
for (int i = 0; i <= 9; i++) {
digitalWrite(LED, HIGH);
delay(100);
}
}
void setup() {
// put your setup code here, to run once:
// pin setup
pinMode(LED, OUTPUT);
pinMode(BUTTONPIN, INPUT_PULLUP);
attachInterrupt(BUTTONPIN, trigger_led, RISING); // attach the interrupt function to the button press
// serial setup
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // wait some time
on();
}