PiicoDev RGB LED Module - Raspberry Pi Guide

Updated 15 November 2021

Let's get started with the PiicoDev® 3x RGB LED Module. In this guide, we'll connect the LED Module to our Raspberry Pi Pico and get it working with some example code to display colourful patterns.

To follow along, it's best to have:

If you prefer not to use the PiicoDev Adapter for Raspberry Pi, there are other connection options in our PiicoDev Connection Guide.

If you haven't set up a Raspberry Pi to be used as a desktop computer before, head over to our Raspberry Pi Workshop for Beginners to get started.


Connect the RGB LED Module to your Pi

Mount the PiicoDev Adapter on your Raspberry Pi and plug connect your RGB Module to the Adapter with the PiicoDev cable.

Ensure both ID switches are OFF, and both ID jumpers (on the back side) are unsoldered.

If you're unfamiliar with connecting PiicoDev "Smart" Modules, read the PiicoDev Connection Guide before proceeding.


Enable I2C

Power on your Raspberry Pi. Open the Raspberry Pi Configuration Menu, select the Interfaces tab and ensure I2C is enabled.

You should only need to do this step for your first PiicoDev project.


Install/Upgrade PiicoDev

Open Thonny (Pi Start Menu > Programming > Thonny IDE) and open the Manage Packages menu (Tools > Manage Packages)


Search for 'piicodev' and install or upgrade if necessary.

search-for-piicodev-pypi     install-piicodev-package

Download Example script

Download the example script main.py (right-click, "save link as") and open it in Thonny. This script is ready to run so click the run button to see a demonstration of some features.

The demos, in order, are:

  • Colour individual pixels
  • Clear the LEDs
  • Fill the LEDs with a colour from the colour wheel, and toggle the "Power" LED

It will be best to keep these files wherever you like to keep your coding projects eg. /home/pi/PiicoDev

Remix - Fade LEDs

In this remix, we'll use loops to animate the LEDs, glowing them on then off. Copy the following code and paste it into main.py. Re-run main.py to observe the results.

from PiicoDev_RGB import PiicoDev_RGB
from PiicoDev_Unified import sleep_ms # Cross-platform compatible sleep function

leds = PiicoDev_RGB() # initialise the LED module with conservative default brightness

while True:
    for x in range(255): # glow on
        leds.fill( [x, 0, 0] ) # fill() will automatically show()
    for x in range(255,0,-1): # glow off
        leds.fill( [x, 0, 0] ) # fill() will automatically show()

Multiple Modules (Traffic Lights)

We can control multiple LED Modules by setting unique IDs using the on-board switches and jumpers. For this remix, leave one module with all its switches cleared (off) and set ID 1 on the second module. Make sure the solder jumpers on the rear of each module are open (unsoldered)

The following code initialises two LED modules to be controlled independently. This is done by setting the id argument of the second module to indicate the switch positions: [1,0,0,0]. For this module, only the first switch is ON, and so we put a 1 in the first position. If we closed the second switch instead, we would use id=[0,1,0,0].

To learn more about PiicoDev Modules with ID options, read our PiicoDev Connection Guide (Smart Modules).

from PiicoDev_RGB import PiicoDev_RGB
from PiicoDev_Unified import sleep_ms # Cross-platform compatible sleep function

trafficA = PiicoDev_RGB() # initialise an RGB LED module with default address (all switches OFF)
trafficB = PiicoDev_RGB(id=[1,0,0,0]) # initialise RGB LED module using switch positions (first switch ON, all others OFF)

red = [255,0,0]
amber = [225,165,0]
green = [0,255,0]

while True:
    ### Traffic flows one way
    trafficA.clear(); trafficB.clear()
    trafficA.setPixel(2, green); trafficA.show()
    trafficB.setPixel(0, red); trafficB.show()
    ### Transition
    trafficA.setPixel(1, amber); trafficA.show()
    ### Traffic flows the other way
    trafficA.clear(); trafficB.clear()
    trafficA.setPixel(0, red); trafficA.show()
    trafficB.setPixel(2, green); trafficB.show()
    ### Transition
    trafficB.setPixel(1, amber); trafficB.show()



setPixel(n, colour) will set led # n to the RGB colour colour = [r,g,b] where r,g,b are 0-255

Once the pixels are set with setPixel(), the new values must be pushed to the physical LEDs with show().


Updates the physical LEDs with data set by eg. setPixel().


Blanks all the RGB LEDs. It is not necessary to call show() after calling clear().


setBrightness(x) controls the maximum brightness of the RGB LEDs, where x may be between 0-255. This function is useful to avoid being dazzled by the bright LEDs, or to keep current consumption low.


fill(colour) will fill all RGB LEDs with the colour specified by the RGB list colour. Automatically updates the LEDs by calling show()


wheel(i) returns an RGB colour list [r,g,b] colour from the colour wheel, where i is the angle (in degrees) on the wheel. You don't have to constrain i to between 0-360, i will wrap the colour wheel.


pwrLED(True/False) will set the LED to True = on, False = off

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.


Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.