picstart1 wrote:The code below only calls blink one timeCode: Select allled = 8
i=1
ledstate=0
gpio.mode(led,gpio.OUTPUT)
tmr.alarm(1000,1,blink())
function blink()
print(i)
if ledstate==0 then
gpio.write(led,gpio.HIGH)
ledstate=1
else
gpio.write(led,gpio.LOW)
ledstate=0
end
i=i+1
if i==10 then
print("stop")
tmr.stop()
end
print("blinked")
end
the code below worksCode: Select allled = 8
i=1
ledstate=0
gpio.mode(led,gpio.OUTPUT)
tmr.alarm(1000,1,
function ()
print(i)
if ledstate==0 then
gpio.write(led,gpio.HIGH)
ledstate=1
else
gpio.write(led,gpio.LOW)
ledstate=0
end
i=i+1
if i==10 then
print("stop")
tmr.stop()
end
print("blinked")
end
)
The only difference is the function isn't named and is inline with tmr.alarm
Is this my error or a bug?
trying to put function definition before tmr.alarm() call may be?
I don't get my unit handy, can't test it.