RGB Panel Hookup Guide


Contributors: Jimb0

Example Sketch

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.

Check out the codebender.cc embed below. If that doesn’t load for you, you can click here to download the sketch.

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):

  • Movement: w, a, s, d (up, down, left, right)
  • Draw Pixel: Spacebar
  • Erase Pixel: e
  • Erase Screen: E
  • Fill screen with active color: f
  • Color Control:
    • Red value up: R (values between 0 [off] and 7 [most bright])
    • Red value down: r
    • Green up/down: G/g
    • Blue up/down: B/b
    • Copy color: z (copies a color under the cursor)
  • Shape Drawing:
    • Line: press v to place starting point. Then move cursor to endpoint and press v again.
    • Rectangle: press x or X to place first corner. Then move your cursor to where you want the diagonal corner. Then press either x for an empty box, or X for a filled box.
    • Circle: press c or C to place the center of the circle. Then move your cursor to where you want the outside edge of your circle to be. Then press c for an empty circle or C for a filled circle.
  • Text: press t to 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 p to 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 l to 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:

32x32 panel image

An example drawing on the 32x32 panel.

alt text

A drawing on the 16x32 panel.

Don’t laugh. I drew that SFE flame one pixel at a time!

Want more information about SparkFun's classes? Interested in getting involved with teaching electronics? Just want to talk? Sign up for our newsletter, or contact our education department.

SparkFun is a company built around one core idea – sharing ingenuity. We think everyone should have the hardware and resources to learn and play with cool electronic gadgetry.

Share, give, learn, SparkFun.

Do you regularly instruct classes and workshops in a formal or informal learning environment? SparkFun offers Educator Discounts to people teaching and sharing electronics.

Find out more.