ESP32 I'm having trouble lighting an LED with a simple button.
-
- Posts: 44
- http://meble-kuchenne.info.pl
- Joined: Sun Mar 21, 2021 2:13 pm
- Has thanked: 18 times
- Been thanked: 1 time
ESP32 I'm having trouble lighting an LED with a simple button.
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.
- Attachments
-
- led-esp.PNG (46.54 KiB) Viewed 3712 times
-
- Valued Contributor
- Posts: 1628
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
Re: ESP32 I'm having trouble lighting an LED with a simple button.
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
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.
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.mnfisher wrote: ↑Fri Nov 01, 2024 2:34 amThe 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
- Attachments
-
- led-esp.PNG (89.15 KiB) Viewed 3637 times
-
- ESP-LED-BUTON-1.fcfx
- (11.99 KiB) Downloaded 145 times
-
- Valued Contributor
- Posts: 1628
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 761 times
Re: ESP32 I'm having trouble lighting an LED with a simple button.
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
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
-
- Valued Contributor
- Posts: 1065
- Joined: Wed Dec 02, 2020 10:53 am
- Has thanked: 201 times
- Been thanked: 225 times
Re: ESP32 I'm having trouble lighting an LED with a simple button.
Hi Ayhan
Can you try this version?
I chanched the switch.
Can you try this version?
I chanched the switch.
- Attachments
-
- ESP-LED-BUTON-1_mod.fcfx
- (11.99 KiB) Downloaded 144 times
Re: ESP32 I'm having trouble lighting an LED with a simple button.
Thank you for your quick reply. I did 10ms, nothing changed. Very interesting.mnfisher wrote: ↑Fri Nov 01, 2024 10:00 amTry 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
-
- Matrix Staff
- Posts: 1550
- Joined: Sat Dec 05, 2020 10:32 am
- Has thanked: 214 times
- Been thanked: 362 times
Re: ESP32 I'm having trouble lighting an LED with a simple button.
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?
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?
-
- Matrix Staff
- Posts: 2086
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 644 times
- Been thanked: 702 times
Re: ESP32 I'm having trouble lighting an LED with a simple button.
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.
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.
Martin