ESP32 I'm having trouble lighting an LED with a simple button.

For general Flowcode discussion that does not belong in the other sections.
Post Reply
ayhan1
Posts: 44
http://meble-kuchenne.info.pl
Joined: Sun Mar 21, 2021 2:13 pm
Has thanked: 18 times
Been thanked: 1 time

Flowcode v10 ESP32 I'm having trouble lighting an LED with a simple button.

Post 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.
Attachments
led-esp.PNG
led-esp.PNG (46.54 KiB) Viewed 3715 times

mnfisher
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.

Post 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

ayhan1
Posts: 44
Joined: Sun Mar 21, 2021 2:13 pm
Has thanked: 18 times
Been thanked: 1 time

Re: ESP32 I'm having trouble lighting an LED with a simple button.

Post 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.
Attachments
led-esp.PNG
led-esp.PNG (89.15 KiB) Viewed 3640 times
ESP-LED-BUTON-1.fcfx
(11.99 KiB) Downloaded 145 times

mnfisher
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.

Post 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

stefan.erni
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.

Post by stefan.erni »

Hi Ayhan

Can you try this version?

I chanched the switch.
2024-11-01_11-03-51.PNG
2024-11-01_11-03-51.PNG (3.02 KiB) Viewed 3631 times
Attachments
ESP-LED-BUTON-1_mod.fcfx
(11.99 KiB) Downloaded 145 times

ayhan1
Posts: 44
Joined: Sun Mar 21, 2021 2:13 pm
Has thanked: 18 times
Been thanked: 1 time

Re: ESP32 I'm having trouble lighting an LED with a simple button.

Post 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.

Steve-Matrix
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.

Post 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?

medelec35
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.

Post 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.
Martin

Post Reply