The awesome thing about the Arduino is that there is usually a nice set of libraries already written for almost anything you'd like to connect to it. I'm using the u8glib to drive the LCD. This library allows us to concentrate on our game rather than on how to control the LCD.



In the Arduino IDE, install the u8glib library:

Sketch > Include Library > Manage Libraries > enter u8glib > Click to select then click Install.

Let's start with an example:

File > Examples > u8glib > HelloWorld

The u8g library supports an insanely long list of display varieties! It even drives some printers!

So, the first thing we need to do is tell the library which LCD screen we have. Google showed me that my Nokia 5110 uses a PCD8544 chip to draw the LCD, so I uncommented this line:

U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8

The SCK and MOSI lines MUST be connected to 13 and 11. However, the other pins could be any digital Arduino pins.

For aesthetic reasons, I decided to line up the LCD pins with the Arduino pins and modified the parameters to:

U8GLIB_PCD8544 u8g(13, 11, 9, 8, 10); // SPI Com: SCK = 13, MOSI = 11, CS = 9, A0/DataCommand = 8, Reset = 10

However, you could keep the same code, just make sure that wire up the pins accordingly.

Upload the sketch by clicking on the arrow next to the checkmark. You can also use the keyboard shortcut Control/Command - U.

You should see, surprise surprise... Hello World.