Page 1 of 1
ESP32 I'm having trouble lighting an LED with a simple button.
Posted: Thu Oct 31, 2024 11:04 pm
by ayhan1
hello. I usually work with PIC series microcontrollers. I have been using flowco for a long time. Recently, I started working with esp32 wroom32. But with esp32, I made an example of led lighting with a simple button. When the button is pressed, the led will light up and turn off when you release it. But when I press and hold the button, the led blinks. There is absolutely no blink in the program. Why does he do this? Button 22 is connected to pin 23 led.
Re: ESP32 I'm having trouble lighting an LED with a simple button.
Posted: Fri Nov 01, 2024 2:34 am
by mnfisher
The esp 32 will be crashing with a watch dog timer error.
The esp32 is slightly different to program on that the is an operating system (RTOS) that is multi-tasking and all programs must yield to allow this to happen.
Add a small delay to your loop and all will be well - the delay passes control back to RTOS allowing the task scheduler to work.
Martin
Re: ESP32 I'm having trouble lighting an LED with a simple button.
Posted: Fri Nov 01, 2024 9:46 am
by ayhan1
mnfisher wrote: ↑Fri Nov 01, 2024 2:34 am
The esp 32 will be crashing with a watch dog timer error.
The esp32 is slightly different to program on that the is an operating system (RTOS) that is multi-tasking and all programs must yield to allow this to happen.
Add a small delay to your loop and all will be well - the delay passes control back to RTOS allowing the task scheduler to work.
Martin
Hello. Thank you for your reply. Unfortunately, nothing has changed. I added many from 2 microseconds to 200 milliseconds, but the problem did not improve. It shouldn't be this hard to turn a led on and off. An interesting situation. The program I made is attached.
Re: ESP32 I'm having trouble lighting an LED with a simple button.
Posted: Fri Nov 01, 2024 10:00 am
by mnfisher
Try 10ms. (2uS isn't long enough - 200ms should be plenty though)
I would also probably read the state of the switch and just alter the LED state if it has changed.
Also open a COM port to the esp32 (try PuTTY for example) - by default it outputs quite a lot of debug info...
Martin
Re: ESP32 I'm having trouble lighting an LED with a simple button.
Posted: Fri Nov 01, 2024 10:05 am
by stefan.erni
Hi Ayhan
Can you try this version?
I chanched the switch.

- 2024-11-01_11-03-51.PNG (3.02 KiB) Viewed 3633 times
Re: ESP32 I'm having trouble lighting an LED with a simple button.
Posted: Fri Nov 01, 2024 10:24 am
by ayhan1
mnfisher wrote: ↑Fri Nov 01, 2024 10:00 am
Try 10ms. (2uS isn't long enough - 200ms should be plenty though)
I would also probably read the state of the switch and just alter the LED state if it has changed.
Also open a COM port to the esp32 (try PuTTY for example) - by default it outputs quite a lot of debug info...
Martin
Thank you for your quick reply. I did 10ms, nothing changed. Very interesting.
Re: ESP32 I'm having trouble lighting an LED with a simple button.
Posted: Fri Nov 01, 2024 10:52 am
by Steve-Matrix
A few other suggestions. You may have done all of these already, but I'm just trying to rule out some real basics and to isolate the issue.
Does an LED flasher work? If it did, then the problem is specific to the switch.
And how about accessing the i/o pins directly? That is, replace ReadState with an input icon (and the TurnOn/TurnOff with output icons if the flasher is also not working).
If there's still a problem then how about a simple program that sets all outputs high and then stops with a loop forever? If this fails, then it's a hardware issue I guess. I've also seen boards that require the reset pin to be pressed after programming.
And any errors showing in the compiler output?
Re: ESP32 I'm having trouble lighting an LED with a simple button.
Posted: Fri Nov 01, 2024 11:31 am
by medelec35
Hello.
I have tested the switch for in simulation mode and on embedded.
I have replicated the issue for simulation mode.
All works on hardware.
Thank you for bring this to my attention, I will fix the issue ASAP.