Data Sheet

28
WHITE = string.char(ON, ON, ON)
BLACK = string.char( 0, 0, 0)
function colourWheel(index)
if index < 85 then
return string.char(index * 3 * BRIGHT, (255 - index * 3) * BRIGHT, 0)
elseif index < 170 then
index = index - 85
return string.char((255 - index * 3) * BRIGHT, 0, index * 3 * BRIGHT)
else
index = index - 170
return string.char(0, index * 3 * BRIGHT, (255 - index * 3) * BRIGHT)
end
end
rainbow_speed = 8
function rainbow(index)
buffer = ""
for pixel = 0, 7 do
buffer = buffer .. colourWheel((index + pixel * rainbow_speed) % 256)
end
return buffer
end
if true then
ws2812.write(LED_PIN, RED:rep(PIXELS))
tmr.delay(TIME_SLOW)
ws2812.write(LED_PIN, GREEN:rep(PIXELS))
tmr.delay(TIME_SLOW)
ws2812.write(LED_PIN, BLUE:rep(PIXELS))
tmr.delay(TIME_SLOW)
ws2812.write(LED_PIN, WHITE:rep(PIXELS))
tmr.delay(TIME_SLOW)
ws2812.write(LED_PIN, BLACK:rep(PIXELS))
end
rainbow_index = 0
function rainbowHandler()
while(1) do
ws2812.write(LED_PIN, rainbow(rainbow_index))
rainbow_index = (rainbow_index + 1) % 256
end
end
rainbowHandle