; FIGURE 4.
The breakout
board with the
ribbon cable
removed. This
shows the dual
eight-pin
header that
is then
connected
to the
appropriate
pins on the
Arduino Mega
2560 board.
matrix.begin();}
Notice that I changed the clock pin (CLK) to pin 11
because I am using a Mega 2560. You must also choose
the correct define statements, depending on whether
you have a single or double header for data input on the
panel.
Hue/Saturation/Value color model, and takes one long
variable for H, two byte values for S and V, and the
boolean flag for gamma. H values should be in the range
of 0-1535, and S and V 0-255.
The drawPixel method is fairly self-explanatory. The
LED at x, y (each value ranging from 0 to 31 on the 32x32
panel) is turned on when color c is created with one of the
Once these statements are in place, you only need
two lines of code in your program to turn on one of the
LEDs in the panel. For example:
Color methods. Once an LED is turned on, it will remain
on with the color chosen until changed in your program —
as long as the panel is connected to the running Arduino.
unsigned int c = matrix.Color888(0, 200, 0, false); matrix.drawPixel(x, y, c);
The RGBMatrix software takes care of scanning the panel
in the background using the Arduino interrupt. This is a
great feature as it greatly simplifies the code the user
needs to write for operating the panel.
Color Methods
There are several Color methods provided with the
matrix object: Color333, Color444, Color888, and
ColorHSV. Color333( 7, 7, 7) allows three-bit values for the
red, green, and blue parameters; Color444( 15, 15, 15)
allows four-bit values, and Color888(255,255,255, false)
uses eight-bit values, with an optional boolean parameter
on the end to denote whether to use gamma correction
on the color output. I simply set the gamma to false as I
am only using a few colors.
There are quite a number of other software methods
demonstrated in the example software provided and
interested readers can explore these for further
information. There are methods to draw graphic lines,
circles, rectangles, as well as text. With the RGBMatrix
library, it is actually fairly easy to create complex output on
the RGB panel. We have what we need to display the
Game of Life by just picking a color and drawing a pixel
(LED) with that color.
Previous
New
Generation
Generation LED Color
All of these RGB color selector methods reduce the
values to five-bit red, six-bit green, and five-bit blue to fit
the panel’s specifications. I found the Color888 method a
little buggy when values approach the 255 maximum;
therefore, note my use of 200 in the previous example for
a bright green color. The ColorHSV method uses the
0 0 LED off, an empty cell
0 1 Green LED, a new cell born
1 0 Blue LED, a cell dies
1 1 Red LED, cell continues to survive
Table 1.
July 2014 27