I refer the code given for the above practical. I want to keep one of the LEDs to be on for 10 seconds and goes off automatically while the other one works as it is. How can I achieve this by changing the code given? Can some one help me.
Hi Senake, the best way of doing that is to create a timer that starts when you press a button that after checks the amount of time that has passed and automatically turns of the LED after those 10 seconds.
Tomorrow or Wednesday I’ll be posting a new Unit in the Learn ESP32 Course dedicated to create timers with the ESP32, I think after you use that Unit you should be able to modify the web server sketch with the timer.
I’ll let you know when the new Unit is posted.
Thanks!
I’ve just published the Unit that I was talking about: ESP32 with PIR Motion Sensor – Interrupts and Timers
Take a look at the example with the PIR Motion sensor, but basically you want to modify that code to use in your web server sketch. You’ll need to have a startTimer boolean variable that is set to true when you press a button in the web server that will start the timer to turn off the output after X number of seconds.
I hope that helps.
Regards,
Rui