As we begin to think about software for the Game of
Life, it becomes obvious that the model must be based on
a 32x32 numeric array of numbers that represent the
individual LEDs in the panel. However, because we must
look at the eight surrounding numbers of each cell in the
array, we run into a problem when trying to access cell
members that surround the outside edges of the array.
Because of this, there are two approaches to solving
this problem. One is to create a 34x34 array and just use
the interior 32x32 set of cells, allowing the array to have a
border of unused cells. These border cells are then set to
be permanently off which has the effect of sometimes
killing cells around the edges, but it does allow reading the
surrounding neighbor cells without creating a negative
array index. The second — and more involved approach —
is to allow cell growth to wrap around the array. With this
method, cells that move off the top of the array appear at
the bottom, and the same occurs with cells along the
sides. I chose the first method as it was easier.
The Game of Life program flowchart is shown in
Figure 5. In my program, I simply created two arrays of
34x34 bytes using only the interior 32x32 array, set all the
elements to zero, and randomly set 500 locations in the
interior array to the value 1, with 0 representing an LED
that is off, and 1 representing an LED that is on. I call this
seeding the array.
Next, one does the computation for the next
generation. One looks at the eight cells surrounding every
cell in the 32x32 array, sums them up, and uses this sum
to determine if the cell in the new array of 32x32 is set to
a 0 or 1 by the Game of Life rules outlined previously.
After the computations for a new generation are finished,
the new generation is written to the RGB panel. Because I
wanted to utilize the additional colors available in an RGB
display, I decided to make the display of each generation a
little more complicated. Here is what I did.
This adds a lot more color to the display. Because of
the speed of the Arduino and the speed of the display, one
really needs to put a delay in after the new generation is
displayed. If this is not done, the display moves so fast the
interactions are impossible to see. Timing things, I found
that a new generation is displayed about every 50
milliseconds with no delay.
Next in the flowchart, we have to discover if there
have been any changes from one generation to the next. If
the generations are the same, the cells in the Game of Life
have become stable and the display will not change. This is
pretty boring, so we simply restart the process with a new
random seed to the array. If there have been changes from
28 July 2014
RGB Matrix Panel, medium size Adafruit #1484
Power Supply, five volt two amp Adafruit #276
Power Jack, 2.1 mm RadioShack 274-1563
Arduino Mega 2560
2x8 pin header or two 1x8 pin headers
Hookup wire, solder
; FIGURE 6. Schematic.
; FIGURE 5. Game
of Life flowchart.