hw_timer_t *timer1 = NULL;
hw_timer_t *timer2 = NULL;
unsigned int resetTimer = 0;
volatile int counter = 0;
void IRAM_ATTR onTimer400(){
Serial.print("\n");
unsigned int mill = millis();
Serial.print("Pada detik (400ms) ke : ");
Serial.print(mill);
Serial.print(" , Counter: ");
Serial.print(counter);
Serial.print("\n");
counter = counter+1;
}
void IRAM_ATTR onTimer600(){
Serial.print("\n");
unsigned int mill = millis();
Serial.print("Pada detik (600ms) ke : ");
Serial.print(mill);
Serial.print(" , Counter: ");
Serial.print(counter);
Serial.print("\n");
counter = counter-1;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
timer1 = timerBegin(0, 80, true);
timerAttachInterrupt(timer1, &onTimer400, true);
timerAlarmWrite(timer1, 200000, true);
timerAlarmEnable(timer1);
timer2 = timerBegin(1, 80, true);
timerAttachInterrupt(timer2, &onTimer600, true);
timerAlarmWrite(timer2, 300000, true);
timerAlarmEnable(timer2);
}
void loop() {
// put your main code here, to run repeatedly:
}