I burn code with while true loop
this my code
------------------------------------------------------------------------------
yellow = string.char(255, 255, 0)
red = string.char(255, 0, 0)
blue = string.char(0, 0, 255)
green = string.char(0, 255, 0)
purple = string.char(60, 0, 60)
off = string.char(0, 0, 0)
strRain = purple..blue..green..yellow..red
num_leds,back = 20
current_leds,chk_stop = 1
direction = 1
counter = 1
loop = 400
function snake()
remain_leds = 20
if (direction%2 == 1) then
remain_leds = num_leds-current_leds
current_leds = current_leds+1
ws2812.writergb(3,off:rep(current_leds-1)..strRain..off:rep(remain_leds))
back = 20
elseif (direction%2 == 0) then
ws2812.writergb(3,off:rep(back-1)..strRain..off:rep(remain_leds))
back = back-1
remain_leds = remain_leds+1
current_leds = 1
end
if( counter %20 == 0)then
direction = direction+1
end
counter = counter+1
if (counter > loop) then
tmr.stop(1)
counter = 1
direction = 1
chk_stop = 2
end
if (chk_stop == 2) then
counter = 1
direction = 1
chk_stop = 1
end
end
while true do
tmr.alarm(0,200,0,snake() )
end
----------------------------------------------------------------------------