Introduction: Game of Life on Nokia 5110 LCD

About: I am an electronics and communication engineering student currently in my third year. I have an interest towards micro-controllers, electronic circuits and hardware hacking.

The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.

The "game" is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves, or, for advanced "players", by creating patterns with particular properties.

You can read more about it here.

Step 1: Components

1.) Nokia 5110 LCD module, or any other Adafruits' LCD module.

2.) An Arduino Board. I have used Uno.

Step 2: Connections

The nokia 5110 module should only be operated at 3.3V. However, their are sources in the internet which say that it can operate unharmed with 5v too. As for me, I have powered my module from the 3.3V rail, but connected the data pins to the arduino's GPIOs directly, which outputs 5v. I have been using my LCD for 3 days, and haven't seen any negative effects. Also, I have another module by another manufacturer which works only if powered with 5v.

Nokia LCD - Arduino

RST - D3

CE - D4

DC - D5

DIN - D6

CLK - D7

VCC - 3V3

BL -3V3


Also, it is recommended to connect the Back light with a 100 ohm resistor to limit the current drawn.

Step 3: Library

I have used the Adafruit Library to interface the LCD. You can download that from here.

You have to extract the library into the Library folder inside the Arduino folder in order to use it. If you are not familiar with using libraries, refer to this tutorial.

You might notice that there are two header files included in the sketch. Adafruit_PCD8544.h is a device specific library, which contains code to run only philips PCD8544 LCD driver based displays, that is nokia 5110 and 3310. Other such libraries exist for other LCD modules. The most important method in these header files is the drawPixel(int x, int y, int color) method, which tells the LCD where to draw a pixel and of what color.

Adafruit_GFX.h is the other file included. This is the superclass of the other classes. This class contains all the methods which we commonly use, like the method to print stuff on the screen, or draw shapes. It does this by using the drawPixel method. The subclasses override this method to provide device specific implementation. You can read more about it here.

Step 4: Code

The code is included below.

I have stored the states of all the cells in a Boolean array. I update this array according to the rules of Game of Life in each generation.

The size of arena, speed of simulation, etc can be easily modified in the code.

Each cell is shown by 3 X 3 pixels in the LCD. If the cell is alive, the 4 bottom left pixels are darkened. That way, we can easily make out individual pixels. But that limits the size of the universe to 28 X 16 cells.

In order to use another display module, substitute these lines:


Adafruit_PCD8544 LCD = Adafruit_PCD8544(SCLK, DIN, DC, CS, RST);

with the LCD specific header file declaration and object instantiation.