“Life” on a SmartMatrix Board

SmartMatrix Game of Life
Custom controller + SmartMatrix board + Teensy 3.1 with SmartMatrix shield = Conway’s Game of Life

The SmartMatrix board is a 32×32 RGB pixel RGB display (other sizes are available), and it makes an eye-catching display.  There is an existing code library to run it from a Teensy 3.1 with a SmartMatrix Shield. The hardware setup and code library are documented at the pixelmatrix website.  The library has all kinds of cool looking built-in effects, like text scrolling and geometric shapes.

The easiest way to program the Teensy is to add the TeensyDuino extension to the Arduino IDE.  Once the extension is setup, the code can be written in the IDE, and it is loaded onto the Teensy board just like an Arduino.  The only noticeable difference is that the code does not automatically load if the Teensy is running a program.  In that case, you have to press the Teensy’s “reset” button to complete the loading of new code.

Any project on the SmartMatrix board had to look good at a low pixel resolution.  Jason Coon’s implementation of Conway’s Game of Life seemed like an interesting application to run.  Conway’s Game of Life has been around since the 1970s, and it is a “zero-player game”, meaning that you set up an initial state and all subsequent action is determined by the initial setup. To start off, you create a pattern of pixels where each pixel is either “alive” (on) or “dead” (off).  Each pixel has eight adjacent “neighbors” surrounding it – four directly adjacent and four on the diagonal corners.  Each subsequent matrix state is created by the pattern of pixels that exists before it.  The evolution of each “generation” follows only a few simple rules:

This configuration of pixels creates a "glider" which propels itself across the screen in each new generation.
This configuration of pixels creates a “glider” which propels itself across the screen in each new generation.
  1. Any live cell with fewer than 2 live neighbours dies, as if caused by under-population.
  2. Any live cell with 2 or 3 live neighbours lives on to the next generation.
  3. Any live cell with more than 3 live neighbours dies, as if by overcrowding.
  4. Any dead cell with exactly 3 live neighbours becomes a live cell, as if by reproduction.

Jason Coon’s program is visually very appealing.  It creates a random initial state, and evolves from there for 256 generations, using a differently randomly chosen palettes for each set of generations.  I decided to add a user-interactive mode that would allow the user to set a specific initial pixel state.  Adding user interactivity required creation of a controller, so I used a few buttons and switches I had lying around, soldered them to perfboard, and wired the connections to the Teensy.  I 3D printed a custom cover for the controller to make it look a little nicer.

Angle brackets attached to screws on the SmartMatrix board support it upright on the clear acrylic base.
Angle brackets attached to screws on the SmartMatrix board support it upright on the clear acrylic base.

I wanted the display to be free standing, so I built a simple base out of some leftover acrylic pieces I had lying around.  There are four 3 mm screw holes in the back of the SmartMatrix board, so I attached two of them to clear angle brackets which support the board upright on the base.

In “demo” mode, the initial pixel state and palette are chosen automatically and run for 256 generations before starting over again.  In “user” mode, the user selects the initial pixel state with navigation and select buttons on the controller.  In retrospect, I wish I’d added a “start” button, since there’s no obvious way for the user to indicate that she’s done making a pattern and would like to start the game.  My workaround is to have the user press the “left” and “right” buttons simultaneously to start it off.  See the video below for a demo of how the board and controller work:

One thought on ““Life” on a SmartMatrix Board

  1. I saw your page on Game of Life and was inspired enough to track down Jason Coon’s code. I’ve been working on a digital clock project using a 64×64 matrix display for a few months and this was a perfect display option. I got it to compile on the first try! That never happens. I absolutely love the display.
    Brief video at:
    https://www.youtube.com/watch?v=BGXCCDy6IPo
    My write up on the clock is at:
    https://wb8nbs.wordpress.com/2022/07/14/a-clock-with-benefits/
    Also at:
    https://wb8nbs.wordpress.com/2022/07/15/sand-clock-settings/

Leave a Reply

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