Saturday, May 7, 2011

Monochron Clock Game Of Life

Adafruit Industries sells a clock called the Monochron clock. There are a few display styles such as Pong, Space Invaders and Seven Segment LED. My modification was to play John Conway's Game of Life. I based my code on the work done by David Gustafik.

A description of  Life can be found at The rules are simple:

  1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies, as if by overcrowding.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
I have two version of the game of life, one that scales the screen to 64x32 and the other uses that native resolution 128x64.

Life 64x32
There are two arrays each 256 bytes. The first array contains the seed colony or the previous generation. The second array is populated by applying the life rules to the first array. After the new colony is created, it becomes the new display colony and the process repeats.

Because of the 2KB RAM limitation of the ATmega328, I limited the colony to 64x32. The native Monochron display size is 128x64. I scaled this down to 64x32 squares where each square is made of native 2x2 pixels. The colony array is 64x26 to reserve some space at the bottom for the date and time display.

Life 128x64
2K of RAM would be required if the above double RAM buffer approach was used. Instead there is one 1K buffer in RAM and the LCD display is the second  buffer. The LCD display is read into the RAM buffer which is processed using the life rules and the output is written back to the displayThe colony array is 128x53 to reserve some space at the bottom for the date and time display.

This is the 128x64 version.  At the top of each minute the colony is reset using the date and time as a seed.

This is the 64x32 version.

This video shows the clock displaying a birthday message and playing a tune on the hour. The date and time bar is highlighted during the birthday date to notify there is a birthday event that day. The birthday message and the person's name is shown and a tune played on the hour from 8am to 8pm. In addition the message is shown and tune played when the set or increment buttons are pressed.

Here is the code:

Monochron Life Source Code 64x32
Monochron Life Source Code 128x64

My clocks collection can be found in my earlier blog post.


  1. Hello i'm a beginner could you post the monochrom.hex ?
    best regards


  2. Hi Seb,

    I added monochron.hex to the source code download files.