Report Bugs Here

Moderator: Mmiscool

User avatar
By robert badiduwitz
#58685 Having a problem with for next loop on an esp-01 (1 meg black pcb, 8 pins). I a simply trying to flash a neopixel connected to pin 2. When I use the x = x + 1 loop, the unit works perfectly, however when I use a for-next loop to do the same thing, it does not flash the neopixel, but it does seem to run as I get "done" after a short period of time. Any ideas would be useful. I understand that the 1 meg is a "cut down" version, but the for-next should work I think...

First version of code that works fine...

Code: Select allneo.setup(2)
x = 0
[start]
neo(0,255,0,0)
delay 200
neo(0,0,0,0)
delay 200
x = x + 1
if x = 10 then end
goto [start]


This one does not work, but seems to run (no flashing, but gets "done" after a bit...

Code: Select allneo.setup(2)
for x = 0 to 10
neo(0,255,0,0)
delay 200
neo(0,0,0,0)
delay 200
next x
end
User avatar
By Mmiscool
#58720 It seems this is specific to the neo pixel library. I was able to make it work in a for next loop by adding a button and making it so that it exicuted the loop whe. Yhe button was pressed.

Have not figured out the conection as all the other functions seem to work. It might be some thing tied to internal arduino interupts or some thing. For now we can co firm that there is an issue here.
User avatar
By Luc Volders
#58742 Mike and Robert,

I had to try this and found a solution.
The problem is not in the delay functrion but somewhere else.

If you replace:
Code: Select allneo(0,255,0,0)


and
Code: Select allneo(0,0,0,0)


by adding the extra 0 in the command it works:

Code: Select allfor x = 0 to 10
neo(0,255,0,0,0)
delay 200
neo(0,0,0,0,0)
delay 200
next x
end


Maybe that makes your search a bit easier Mike.

Luc