LedStrips are several LEDs joined together into one group.


A LedStrip works similarly to an array of LEDs, its properties are tables that correspond to each LED in the LedStrip. The tables should be addressed with [index].

States {boolean}

A table that maps each of the LED's lit/unlit status.

Colors {color}

A table that maps each of the LED's colors.


This example uses the CPU's Time to select a LED to turn on, such that a light moves on the strip each second. Since the lights will stay on until we tell them not to, the code also gets the previous light to turn off, otherwise all lights on the strip would come on and stay on forever.

function update()
	-- round down cpu time and then truncate to the number of leds in our strip
	local ledToTurnOff = math.floor(gdt.CPU0.Time) % #gdt.LedStrip0.States
	-- we do the same with the next number over to get the adjacent light
	local ledToTurnOn = math.floor(gdt.CPU0.Time+1) % #gdt.LedStrip0.States

	-- since the modulo truncation starts at 0 and the states table starts at 1, we need to add 1 to both numbers
	gdt.LedStrip0.States[ledToTurnOff+1] = false
	gdt.LedStrip0.States[ledToTurnOn+1] = true	

See also the Intro Tutorial video in the official Retro Gadgets YouTube channel for an example to control LED strips with Buttons.