hw_timer_t *My_timer = NULL;
int count = 0;
void IRAM_ATTR onTimer() {
digitalWrite(2, !digitalRead(2));
if ((count == 1) || (count == 2) || (count == 5) || (count == 6) || (count == 9) || (count == 10) || (count == 15) || (count == 17) || (count == 19) || (count == 21) || (count == 23) || (count == 25)) {
digitalWrite(25, HIGH);
}
else if ((count == 3) || (count == 4) || (count == 7) || (count == 8) || (count == 11) || (count == 12) || (count == 13) || (count == 14) || (count == 16) || (count == 18) || (count == 20) || (count == 22) || (count == 24) || (count == 26)) {
digitalWrite(25, LOW);
}
count++;
}
void setup() {
pinMode(2, OUTPUT);
pinMode(25, OUTPUT);
My_timer = timerBegin(0, 40, true);
timerAttachInterrupt(My_timer, &onTimer, true);
timerAlarmWrite(My_timer, 1000000, true);
timerAlarmEnable(My_timer);
}
void loop() {
}