Home » Arduino » Arduino Nokia 3310 LCD Interfacing

Arduino Nokia 3310 LCD Interfacing

Displays are almost always a part of any microcontroller project or embedded system. Fortunately, there are cheap LCDs available with a wide support for multiple microcontroller devices. One is the PCD8544-based liquid crystal display, more popularly known as the Nokia 5110/3310 LCD. This Arduino Nokia 3310 LCD interfacing article covers how to create simple text and graphics using this LCD and the Arduino.

arduino nokia 3310 lcd interfacing

The example codes in this article needs Adafruit's PCD8544 and GFX libraries so go ahead and download and install them first.

Once the libraries are installed, you'll have access to a single example, pcdtest.  This example was built to show all the capabilities of the library. The connections between the Arduino and the Nokia 5110/3310 LCD (which is also on the sketch) is as follows:

D7 -> pin 5 (CLK)
D6 -> pin 4 (DIN)
D5 -> pin 3 (DC)
D4 -> pin 2 (CE)
D3 -> pin 1 (RST)

You can change the pin assignments by editing line 29 on the pcdtest sketch:

The parameters (7, 6, 5, 4, 3) follow the sequence (CLK, DIN, DC, CE, RST).

Go ahead and upload the pcdtest sketch to your Arduino and see the results.

Displaying Text

To display text, you just call the .print() or .println() function. There are also a number of functions associated with displaying text like setting the cursor, text color and size.

Here's an example sketch that displays "hello world" at the top-left corner of the screen with white foreground and black background:

It is necessary to start with .begin() as this initiates the LCD. .setContrast() allows you to tune the darkness or lightness of the display and accepts values from 0 (lightest) to 127 (darkest). You can specify which point you want to place the text within the 84 x 48 screen with .setCursor() and then set the text color with .setTextColor() which accepts background and foreground or foreground only as parameters (obviously, you only have WHITE and BLACK to choose from). .setTextSize() multiplies the text size to the given number. The highest number you can use here is 3. Then you print the text using .print() or .println() (which ends with a new line). Finally, call .display() to update the LCD screen.

Displaying Graphics

By graphics, I mean basic shapes and bitmaps. The Adafruit GFX library enables us to draw from a single pixel to monochrome pictures!

A single pixel can be drawn on the screen using the function:

Where x and y are the coordinates of the pixel and color is either WHITE or BLACK.

For basic shapes, here's the list of functions:

Again, I suggest you toy with the pcdtest sketch which uses the following functions.

To display bitmaps, we use the following command:

Where *bitmap is an array of char constants. Here's an example sketch that draws a 56 x 61 px bitmap image.

Here's what the output should look like:

Snake Game

I managed to create a simple snake game using Arduino and the Nokia 3310 LCD as part of my LANFON project:




Do you have any interesting project using the Nokia 3310 LCD or any other microcontroller project? Contact us and become a writer for TMM!

Leave a Reply

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