LED Matrix – Getting Started with the Feather Wing

LEDs are AWESOME. What’s even better is a MATRIX of them. A matrix allows you to display pictures, text, and animate them. It can display what the weather will be for that day, your agenda for the day or entertaining emojis.

This post will explore getting started with the Matrix panel. You can run them from an Arduino Uno (slower re-fresh), Adafruit M0 (good for animations), Raspberry Pi (multiple matrix panels + internet connection).

We will explore the M0 feather route in this tutorial:

Things you will need:

  1. Matrix of LEDs
  2. Adafruit M0 feather
  3. Adafruit Matrix Backpack
  4. 5V power supply capable of 2 or more amps
  5. Computer with Arduino installed

Preparing Arduino:

Ensure Adafruit libraries are available

Arduino > Tools > Manage Libraries

Search for and install the Adafruit libraries by looking up: “gfx” and “RGB Matrix Panel”

Load an Example

Arduino > File > Examples > RGB matrix Panel > colorwheel_32x32 or which ever dimension your display is.

Adjust for your connections

Because each panel is wired differently we need to adjust for that. We are using the M0 Feather with the Matrix Wing we we need to adjust the following:

Add below code

// FeatherWing pinouts for M0 and M4
#define CLK  13
#define OE   1  // TX
#define LAT  0  // RX
#define A   A5
#define B   A4
#define C   A3
#define D   A2
// the RGB data pins on featherwing, must be on same PORT as CLK
uint8_t rgbpins[] = { 6,5,9,11,10,12 };
 
// Create a 32-pixel tall matrix with the defined pins
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 32, rgbpins);

Ensure you have the M0 board installed

Install both Arduino SAMD and Adafruit SAMD

Ensure your board is selected

Connect your board physically and then ensure your port is selected

Tools > Port > Select your USB connected device

Now, upload to your board!

Sketch > Upload

Lets explore what the code is doing:

#include <RGBmatrixPanel.h>

This is including the library that gives us access to all the good stuff. It allows us to create a panel easily later on and enumerates it as an object.

// FeatherWing pinouts for M0 and M4
#define CLK  13
#define OE   1  // TX
#define LAT  0  // RX
#define A   A5
#define B   A4
#define C   A3
#define D   A2
// the RGB data pins on featherwing, must be on same PORT as CLK
uint8_t rgbpins[] = { 6,5,9,11,10,12 };

This is the pinout for our specific model.

// Create a 32-pixel tall matrix with the defined pins
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 32, rgbpins);

This enumerates an instance of “RGBmatrixPanel” and calls it “matrix”, we pass in the parameters (pin configuration) of the panel. After this is done we can easily address the panel!

matrix.begin();

This kicks off the matrix, it needs to be run before we access any aspect as seen below

matrix.width();
matrix.height();

We can access parameters of the matrix so that we dont need to hard code anything ie we can dynamically do things. This basically passes back the parameters we setup the matrix with. In this case, 32 for both Width and Height

c = matrix.ColorHSV(hue, sat, val, true);

This creates a value that represents a pixels Hue, Satuation and Value. This still needs to be written to the screen.

matrix.drawPixel(x, y, c);

After we know the value we want, we need to write it to the pixel. The above code does this. For a specific X and Y location, write the pixel value C. In this instance, we are writing one pixel at a time, in a loop. This is why it progressively scans onto the matrix. Explore the other example scripts for more features of the library.

Leave a Reply

Your email address will not be published. Required fields are marked *