I have my ESP32 working fine with 4 LEDs using the code from the web server tutorial.
For my project I would need to light the LEDs only while holding the push button, as soon as it would be released, the GPIO should return to “LOW”.
In other words: when touching the push botton on the web server page, I expect only a signal LOW-HIGH-LOW to trigger a connected device.
Can anybody help with such a function?
May be that even introducing a “timer” in the basic code, to reset simply the output state of the GPIO after some milliseconds would do the job – any hint how to implement a timer?
Thanks for a soon reply.
You can use the onmouseup and onmousedown events:https://www.w3schools.com/jsref/event_onmouseup.asp
Here you have an application example: when you click the text, it turns one color, and when you release it changes to another color: https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onmousedown
I hope this helps.