RGB Panel Hookup Guide
Install Arduino Libraries
Our example code is going to make use of Adafruit’s most excellent RGBMatrixPanel library, which also requires their AdafruitGFXLibrary. You can grab both from their GitHub repositories (see our Using GitHub tutorial for help downloading). Or click here to download a zip file of both folders.
Install the libraries into a libraries folder within your Arduino sketchbook. For more help installing libraries, check out our Installing an Arduino Library tutorial.
The RGBMatrixPanel library includes a number of fun examples to help show how the library can be used. They’re awesome. Check them out under the File > Examples > RGBMatrixPanel menu in Arduino. (Definitely check out the Plasma_32x32 or Plasma_16x32 examples!)
Serial Paint Example
We wanted to write another fun sketch that provided an interactive way to explore with the panels and the Arduino library. What we came up with is a Serial-controlled Paint program. With this sketch, you can use the serial monitor (or, better yet, another terminal program) to control a cursor and draw on the matrix.
Before uploading, make sure the sketch is set up to work with your panel. If you’re using a 16x32 panel, you’ll need to make a few changes. Comment out this line (83):
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false); // 32x32
And uncomment this line (85):
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false); // 32x16
Also, 16x32 users should comment out the first
bmp array in the bitmap.h file, and un-comment out the last.
Then upload! After upload, a single pixel should be blinking at the top left of the panel. It doesn’t look like much, but that’s a good sign.
Using the Sketch
To control the program, open up your serial terminal to 9600 bps. Try hitting sending
l (lowercase ‘L’) through the serial monitor, which should load the demo bitmap. You can send
E (uppercase) to erase the screen.
The idea of this sketch is: move the cursor around to draw pixels, shapes, or text. You can see it in action in our New Product Post video:
Here are the commands made available by the sketch (they are case-sensitive):
d(up, down, left, right)
- Draw Pixel:
- Erase Pixel:
- Erase Screen:
- Fill screen with active color:
- Color Control:
- Red value up:
R(values between 0 [off] and 7 [most bright])
- Red value down:
- Green up/down:
- Blue up/down:
- Copy color:
z(copies a color under the cursor)
- Red value up:
- Shape Drawing:
- Line: press
vto place starting point. Then move cursor to endpoint and press
- Rectangle: press
Xto place first corner. Then move your cursor to where you want the diagonal corner. Then press either
xfor an empty box, or
Xfor a filled box.
- Circle: press
Cto place the center of the circle. Then move your cursor to where you want the outside edge of your circle to be. Then press
cfor an empty circle or
Cfor a filled circle.
- Line: press
- Text: press
tto go to text mode. Now any characters received will be displayed on the panel. It’ll wrap around from one line to the next, but not from bottom to top. Press ``` (above Tab / left of 1) to exit text mode.
- Print: press
pto print an array of your drawing to the serial terminal. You can copy this, and put it back in your sketch if you want to load it again.
- Load: press
lto load a pre-defined array from the sketch. The sketch includes a demo array, which was created from the print command. Follow this example to load your own drawings!
Give the paint sketch a try! See if you can make the next great
Lite-Brite LED Panel picture. If you make something neat, share it with us! Here are our creations:
An example drawing on the 32x32 panel.
A drawing on the 16x32 panel.
Don’t laugh. I drew that SFE flame one pixel at a time!