For esp32 using Visual Studio Code, my requirement is when conditions are met - turn on the LED for two seconds. Reset then wait for the conditions to be met again (then turn on LED for two seconds).
I've successfully been able to start and disable the timer the first time the condition is met. Any subsequent time - this does not work.
Is there another way to do this? How can I get this to work?
soundTimer=timerBegin(0,80,true);
timerAttachInterrupt(soundTimer, &onTimer, true);
timerAlarmWrite(soundTimer, 4000000, true);
inside ISR (to disable the timer repeating):
timerEnd(soundTimer);
to trigger timer:
timerAlarmEnable(soundTimer);
I'm receiving these errors (via the Serial monitor):
40 E (75911) timer_group: timer_set_alarm(179): HW TIMER NEVER INIT ERROR
to which I haven't been able to find a resolution.
If hardware timer isn't the best approach - what should I be doing to reliably turn off the LED after two seconds?
HW TIMER NEVER INIT ERRORthen you find a bunch of relevant posts. Predictably, most of those hint that your timer hasn't been initialized.