PiicoDev RGB LED random light show

For the festive season a random light show using the PiicoDev RGB LED Module. Developed on a Pico W it should run on any Pi.

from PiicoDev_RGB import PiicoDev_RGB
from PiicoDev_Unified import sleep_ms
import random
leds = PiicoDev_RGB() # initialise the LED module

c = [ [255, 0, 0], #red
    [0, 255, 0], #green
    [0, 0, 255], #blue
    [255, 255, 0], #yellow
    [255, 0, 255], #magenta
    [0, 255, 255] ] #cyan

while True:
    for l in range(3): #loop through the LEDs
        leds.setPixel(l, c[random.randint(0, 5)]) #pick a random colour
        leds.show()
        sleep_ms(200) #experiment with the loop interval
4 Likes

Hi Fractal,

Thanks for sharing this! :slight_smile:

I gave it a go and it looks great (though Iā€™m a bit late, NYE party lighting instead :slight_smile:?)

2 Likes

Looks beautiful.

For Australia Day here is another light show using the PiicoDev RGB LED Module. It is an improvement on the above since it randomly controls brightness as well as colour. Developed on a Pico W it should run on any Pi.

#This code makes the PiicoDev RGB LED Module display a random light show

from PiicoDev_RGB import PiicoDev_RGB
from PiicoDev_Unified import sleep_ms
import random
leds = PiicoDev_RGB() # initialise the LED module

while True:
    for l in range(3): #loop through the LEDs
        leds.setPixel(l, [random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)]) #pick random RGB values 0-255
        leds.show()
        sleep_ms(50) #try different loop intervals
2 Likes