This tutorial will walk you through building a 3x5 LED matrix controlled by a Raspberry Pi Pico using tscircuit.
Some practical applications of building an LED Matrix include:
The matrix connects to the Pico microcontroller via a data chain. The Pico connects to WiFi through the PICO_W
module.
The components and connections between them are shown in the diagram below:
Let's import the Pico microcontroller and LED components by following the steps in the Importing from JLCPCB section.
We will follow the following steps to build the circuit step by step:
Schematic of the Pico microcontroller imported from JLCPCB is shown below:
We are using IC LEDs (specifically WS2812B), which have an RGB LED and control chip integrated into the same package. These IC LEDs offer several advantages over traditional RGB LEDs:
To connect two LEDs together, we need to connect the data output DO
of the first LED to the data input DI
of the second LED. This creates a chain of LEDs.
The Pico is connected to the LED matrix via a general purpose input/output (GPIO) pin in this example we are using GP6
,
and the other pins of the Pico are connected to ground.
We can connect multiple LEDs together by chaining them, but doing this for a large number of LEDs would be tedious. Luckily, tscircuit has a helper function to create a grid of components. We will be using that helper function to create our matrix layout.
Here we are using the grid
function to create a 3x5 LED matrix. The grid
function takes in the number of columns and rows, and the spacing between the components.
Here we are merging all the learnings from the previous examples to create a complete circuit. The Pico is connected to the LED matrix via the GP6
pin, and the other pins of the Pico are connected to ground.
The GP6
pin is connected to the data input DI
of the first LED, and the data output DO
of each LED is connected to the data input DI
of the next LED in the chain.
While connecting the LEDs together, we are also connecting the GND
and VDD
pins of the LEDs to ground and 5V supply respectively.
Complete circuit is shown below:
We can translate our schematic into a PCB layout by specifying the physical positions of components on the board.
Here we are adding the positions of the components on the PCB:
pcbX={-15} pcbY={0}
with a rotation of 90deg
(Rotation is needed for the Pico to be in the correct orientation)8mm
horizontally and 5mm
verticallyCheck out this circuit in our Playground.
You can order this PCB by downloading the fabrication files and uploading them to JLCPCB. Follow the instructions from here.
The LED matrix can be controlled through a simple web interface that provides a visual grid for controlling individual LEDs. The control system includes:
Web Interface: A 3x5 grid interface where clicking each cell cycles through:
API Integration: The matrix state can be controlled and monitored through REST endpoints, making it easy to integrate with other applications.
Pico W Connection: The matrix connects to WiFi using the Pico W's wireless capabilities, allowing for remote control through the web interface.
The complete implementation, including the web interface and Pico W code, is available in our LED Matrix Server repository.