Raspberry Pi Pico - LED Matrix

This tutorial instructs you how to use Raspberry Pi Pico with LED matrix display modules. In detail, you will learn:

Then, you can easily change the code for different LED matrices such as the 16x8 or 64x8 LED matrix.

Raspberry Pi Pico LED Matrix

Hardware Preparation

1×Raspberry Pi Pico W
1×Raspberry Pi Pico (Alternatively)
1×Micro USB Cable
1×FC-16 LED Matrix 32x8
1×FC-16 LED Matrix 8x8
1×Jumper Wires
1×Breadboard
1×DC Power Jack
1×5V Power Adapter for Raspberry Pi Pico
1×(Optional) Screw Terminal Expansion Board for Raspberry Pi Pico

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables.

Overview of LED Matrix

LED Matrix display

There are various types of LED matrices, but the MAX7219-based LED matrix is commonly used with Raspberry Pico. The MAX7219-based LED matrix has the following features:

  • The basic unit of an LED matrix is a block.
  • Each block consists of an 8x8 LED matrix (64 LEDs) and a MAX7219 driver.
  • LED matrices can be formed using a single block or by chaining multiple blocks together.
  • Pre-assembled LED matrices with multiple blocks are available (e.g., 4-in-1, 8-in-1 configurations).
  • Alternatively, you can purchase individual blocks and wire them together to create a matrix of your desired size. You can also chain 1-in-1, 4-in-1, 8-in-1 LED Matrix together
  • You must specify the size of the LED matrix in your Raspberry Pico code.

Pinout

LED Matrix Pinout

A LED Matrix consists of one or more sections. Each section has two types of connectors:

  • Group of Input Pins:
    • VCC: Connect to the 5V.
    • GMD: Connect to the GND.
    • DIN: This is the Data pin. Connect to the SPI MOSI pin on the Raspberry Pi Pico.
    • CS: Chip Select. Connect to any digital pin on the Raspberry Pi Pico.
    • CLK: Clock pin. Connect to the SPI CLK pin on the Raspberry Pi Pico.
  • Group of Output Pins:
    • VCC: Connect this to VCC on the next module.
    • GND: Connect this to GMD on the next module.
    • DOUT: Data Out. Connect to the DIN pin on the next module.
    • CS: Connect this to CS on the next module.
    • CLK: Connect this to CLK on the next module.

Wiring Diagram

If the LED matrix has only one block:

  • Attach the groups of input pins to the Raspberry Pi Pico.
  • Do not connect the groups of output pins.
The wiring diagram between Raspberry Pi and Pico 8x8 LED matrix FC-16

This image is created using Fritzing. Click to enlarge image

If the LED matrix is already put together into several sections:

  • Connect the input pins group to the Raspberry Pi Pico.
  • Do not connect the output pins group.
The wiring diagram between Raspberry Pi and Pico LED matrix display

This image is created using Fritzing. Click to enlarge image

If you put together the LED matrix using different components:

  • Connect the first block's input pins to the Raspberry Pi Pico.
  • Connect each block's output pins to the next block's input pins.
  • Do not connect the last block's output pins.
Raspberry Pi Pico 32x8 LED matrix wiring FC-16 diagram

This image is created using Fritzing. Click to enlarge image

The display consumes a significant amount of power. If it appears dim or if some parts of the LED matrix are not displaying properly, use a 5V external power supply to power the LED matrix display. The wiring diagram below illustrates how to connect an external power source to the LED matrix:

The wiring diagram between Raspberry Pi and Pico dot matrix external power display

This image is created using Fritzing. Click to enlarge image

Raspberry Pi Pico - LED Matrix Code

The provided code is designed for a 32x8 FC-16 LED matrix display that includes four blocks. It can be adjusted to fit different sizes such as 8x8, 16x8, 64x8, etc.

""" This Raspberry Pi Pico MicroPython code was developed by newbiely.com This Raspberry Pi Pico code is made available for public use without any restriction For comprehensive instructions and wiring diagrams, please visit: https://newbiely.com/tutorials/raspberry-pico/raspberry-pi-pico-led-matrix """ from machine import Pin, SPI from time import sleep from DIYables_MicroPython_LED_Matrix import Max7219 # Example usage: # Initialize SPI and CS pin spi = SPI(0, baudrate=10000000, polarity=0, phase=0, sck=Pin(18), mosi=Pin(19)) cs = Pin(21, Pin.OUT) # Initialize the Max7219 class display = Max7219(spi, cs, num_matrices=4) display.set_brightness(15) # Adjust brightness from 0 to 15 # Clear the display display.clear() # Render text on the display display.print("11°C", col = 2) display.show()

Detailed Instructions

Please follow these instructions step by step:

  • Ensure that Thonny IDE is installed on your computer.
  • Ensure that MicroPython firmware is installed on your Raspberry Pi Pico.
  • If this is your first time using a Raspberry Pico, refer to the Raspberry Pi Pico - Getting Started tutorial for detailed instructions.
  • Connect the Raspberry Pi Pico board to the LED matrix according to the provided diagram.
  • Connect the Raspberry Pi Pico to your computer using a USB cable.
  • Launch the Thonny IDE on your computer.
  • On Thonny IDE, select MicroPython (Raspberry Pi Pico) Interpreter by navigating to Tools Options.
  • In the Interpreter tab, select MicroPython (Raspberry Pi Pico) from the drop-down menu.
  • Ensure the correct port is selected. Thonny IDE should automatically detect the port, but you may need to select it manually (e.g., COM3 on Windows or /dev/ttyACM0 on Linux).
  • Navigate to the Tools Manage packages on the Thonny IDE.
  • Search “DIYables-MicroPython-LED-Matrix”, then find the LED Matrix library created by DIYables.
  • Click on DIYables-MicroPython-LED-Matrix, then click Install button to install LED Matrix library.
Raspberry Pi Pico LED Matrix library
  • Copy the above code and paste it to the Thonny IDE's editor.
  • Save the script to your Raspberry Pi Pico by:
    • Click the Save button, or use Ctrl+S keys.
    • In the save dialog, you will see two sections: This computer and Raspberry Pi Pico. Select Raspberry Pi Pico
    • Save the file as main.py
  • Click the green Run button (or press F5) to run the script. The script will execute.
  • Check out the LED matrix. It looks like the below:
Raspberry Pi Pico LED matrix display text

The actual display lighting looks much better than in the image. The camera is unable to capture the true color of the lighting.

Raspberry Pi Pico LED Matrix Code – Scrolling Text

When your message is too long for a LED matrix display, you can make it scroll across the screen. The below MicroPython code for Raspberry Pi Pico shows how to move a message across the LED matrix display.

""" This Raspberry Pi Pico MicroPython code was developed by newbiely.com This Raspberry Pi Pico code is made available for public use without any restriction For comprehensive instructions and wiring diagrams, please visit: https://newbiely.com/tutorials/raspberry-pico/raspberry-pi-pico-led-matrix """ from machine import Pin, SPI from time import sleep from DIYables_MicroPython_LED_Matrix import Max7219 # Example usage: # Initialize SPI and CS pin spi = SPI(0, baudrate=10000000, polarity=0, phase=0, sck=Pin(18), mosi=Pin(19)) cs = Pin(21, Pin.OUT) # Initialize the Max7219 class display = Max7219(spi, cs, num_matrices=4) display.set_brightness(15) # Adjust brightness from 0 to 15 def scroll_text(message): # Scroll the message from right to left display.print(message, col = 32) # Text starts from the right (x=32) and moves left for i in range(len(message) * 8 + 32): # Scroll through the entire message display.clear() display.print(message, col = 32 - i) # Move text from right to left display.show() sleep(0.05) # change speed here while True: scroll_text("Hello, DIYables") # Change text as needed

Detailed Instructions

  • Copy the provided Raspberry Pi Pico MicroPython code and paste it into Thonny's editor.
  • Save the MicroPython code to your Raspberry Pi Pico board.
  • Click the green Run button (or press F5) to execute the code.
  • Check out the LED matrix. The scrolling effect looks like the below:

Raspberry Pi Pico LED Matrix - Custom Characters

To display special characters or symbols such as a heart or an angry bird on an LED Matrix display, you need to use the character generator.

The character generator makes a character (64 pixels). You just need to follow these steps:

Click on each pixel to select/deselect


Copy below custom character code
Replace the custom_char in the Raspberry Pi Pico code

The below code shows three custom characters on the LED Matrix 32x8:

""" This Raspberry Pi Pico MicroPython code was developed by newbiely.com This Raspberry Pi Pico code is made available for public use without any restriction For comprehensive instructions and wiring diagrams, please visit: https://newbiely.com/tutorials/raspberry-pico/raspberry-pi-pico-led-matrix """ from machine import Pin, SPI from time import sleep from DIYables_MicroPython_LED_Matrix import Max7219 # Example usage: # Initialize SPI and CS pin spi = SPI(0, baudrate=10000000, polarity=0, phase=0, sck=Pin(18), mosi=Pin(19)) cs = Pin(21, Pin.OUT) # Initialize the Max7219 class display = Max7219(spi, cs, num_matrices=4) display.set_brightness(15) # Adjust brightness from 0 to 15 # Clear the display display.clear() display.show() custom_char_1 = [ 0b00000000, 0b00000000, 0b00000000, 0b11110000, 0b00000000, 0b00000000, 0b00000000, 0b00000000 ] custom_char_2 = [ 0b00000000, 0b01101100, 0b10010010, 0b10000010, 0b10000010, 0b01000100, 0b00101000, 0b00010000 ] custom_char_3 = [ 0b00000000, 0b00100000, 0b00010000, 0b11111000, 0b00010000, 0b00100000, 0b00000000, 0b00000000 ] # Clear the display display.clear() display.print_custom_char(custom_char_1, col = 0) display.print_custom_char(custom_char_2, col = 4) display.print_custom_char(custom_char_3, col = 11) display.show()

Detailed Instructions

  • Copy the provided Raspberry Pi Pico MicroPython code and paste it into Thonny's editor.
  • Save the MicroPython code to your Raspberry Pi Pico board.
  • Click the green Run button (or press F5) to execute the code.
  • Check out the LED matrix. It looks like the below:
Raspberry Pi Pico LED matrix custom characters

Learn More

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!