Interfacing PIC18F4550 MCU with NOKIA 5110 LCD

This post shows how interface PIC18F4550 microcontroller with Nokia 5110 (Nokia 3310) graphical LCD screen. In this project I’m going to use CCS PIC C compiler.
The name Nokia 5110 (3310) comes from Nokia 5110 (or Nokia 3310) mobile phone. The Nokia 5110 LCD has a controller named PCD8544, it is similar to the Nokia 5110 mobile phone LCD, it uses SPI interface protocol with maximum clock frequency of 4MHz, it requires 5 control pins (at most), it’s low cost and easy to use.

The resolution of this LCD is 84 x 48 which means it has 4032 pixels. This module works with 3.3V only and it doesn’t support 5V (it’s not 5V tolerant), that means interfacing it with 5V microcontroller such as PIC18F4550 may require voltage level shifter.

Nokia 5110 driver for CCS C compiler:
To simplify the interfacing C code, I wrote a simple driver (library) for the Nokia 5110 LCD (PCD8544 controller).
This small driver and graphics library allows us to print texts, draw lines, circles and many other function (listed below). This library is just a .C file named NOKIA5110.C which can be installed by adding it to project folder or CCS C compiler drivers folder (for example: C:\Program Files\CCS\Drivers)

The Nokia 5110 LCD library can be downloaded from the link below:
Nokia 5110 LCD driver for CCS C compiler

The SPI bus has to be initialized in the main code as the example shown below where the hardware SPI module is used with a clock frequency of 1MHz (1000000Hz):
#use spi(SPI1, BAUD = 1000000, MODE = 3, BITS = 8, STREAM = LCD_STREAM)

The other LCD pins also have to be defined in the main code as the example shown below where RST (rest) pin is connected to RD0, CS (chip select) pin is connected to RD1 and DC (data/command) pin is connected to RD2:
#define LCD_RST PIN_D0
#define LCD_CS PIN_D1
#define LCD_DC PIN_D2

Driver functions:
LCD_Begin(): this function initializes the Nokia 5110 LCD.
LCD_SetContrast(con): sets the contrast of the display where: 0 <= con <= 63 .
LCD_Display(): prints data buffer on the display, must be called after any draw action.

LCD_Clear(): clears the whole LCD.
LCD_Fill(): fills the whole LCD (writes all LCD pixels).
LCD_TextSize(t_size): sets text size.
LCD_GotoXY(x, y): move cursor to position (x, y), x and y are in pixel.
LCD_TextWrap(w): sets text wrap, if w = 1 text wrap enabled (default), if w = 0 text wrap disabled.
LCD_Print(c): prints a character c on the LCD.
LCD_Invert(inv): inverts the display, inv may be 1 or 0.

LCD_DrawPixel(x, y, color): draws one pixel on the screen, x and y are the coordinates in pixel, color may be 1 or 0 (1 is default).
LCD_DrawLine(x0, y0, x1, y1, color): draws a line from (x0, y0) to (x1, y1). Color may be 1 or 0, 1 draw and 0 delete, default value is 1 (true).
LCD_DrawHLine(x, y, w, color): draws a horizontal line from (x, y) with width of w. Color can be 1 or 0.
LCD_DrawVLine(x, y, h, color); draws a vertical line from (x, y) with height of h. Color can be 1 or 0.

LCD_DrawRect(x, y, w, h): draws a rectangle from (x, y) with width w and height h.
LCD_FillRect(x, y, w, h, color): fills a rectangle from (x, y) with width w and height h. Color can be 1 or 0.
LCD_DrawRoundRect(x, y, w, h, r): draws round rectangle from (x, y) with width w, height h and radius r.
LCD_FillRoundRect(x, y, w, h, r, color): fills round rectangle from (x, y) with width w, height h & radius r.

LCD_DrawTriangle(x0, y0, x1, y1, x2, y2): draws a triangle with points (x0, y0), (x1, y1) and (x2, y2).
LCD_FillTriangle(x0, y0, x1, y1, x2, y2, color): fills a triangle with points (x0, y0), (x1, y1) and (x2, y2).

LCD_DrawCircle(x0, y0, r): draws a circle from (x0, y0) with radius r.
LCD_FillCircle(x0, y0, r, color): fills a circle from (x0, y0) with radius r.
LCD_DrawCircleHelper(x0, y0, r, cornername): draws a circle helper from (x0, y0) with radius r and cornername.
LCD_FillCircleHelper(x0, y0, r, cornername, delta, color): fills a circle helper from (x0, y0) with radius r and cornername.

LCD_ROMBMP(x, y, *bitmap, w, h, color): draws a bitmap which is stored in ROM.
LCD_RAMBMP(x, y, *bitmap, w, h, color): draws a bitmap which is stored in RAM.

Interfacing PIC18F4550 with Nokia 5110 LCD:

PIC18F4550 MCU with Nokia 5110 LCD

Hardware Required:

  • PIC18F4550 microcontroller
  • Nokia 5110 (3310) LCD module
  • AMS1117 3V3 voltage regulator
  • 10 uF capacitor
  • 100 nF ceramic capacitor
  • 5 x 3.3k ohm resistor
  • 5 x 2.2k ohm resistor
  • 5V source
  • Breadboard
  • Jumper wires

Interfacing PIC18F4550 MCU with NOKIA 5110 LCD circuit:
The following image shows project circuit diagram.

PIC18F4550 Nokia 5110 LCD circuit

All the grounded terminals are connected together.

The Nokia 5110 which is shown in the circuit diagram has 8 pins (from left to right): RST (reset), CE (chip enable), DC (or D/C: data/command), Din (data in), Clk (clock), VCC (3.3V), BL (back light) and Gnd (ground).

As mentioned above, the Nokia 5110 LCD works with 3.3V only (power supply and control lines). The LCD module is supplied with 3.3V which comes from the AMS1117 3V3 voltage regulator, this regulator steps down the 5V into 3.3V.

All PIC18F4550 microcontroller output pins are 5V, connecting a 5V pin to the Nokia 5110 LCD could damage its controller circuit!
To connect the PIC18F4550 to the LCD module, I used voltage divider for each line which means there are 5 voltage dividers. Each voltage divider consists of 2.2k and 3.3k resistors, this drops the 5V into 3V which is sufficient.

So, the Nokia 5110 LCD pins are connected to PIC18F4550 MCU as follows (each one through voltage divider):
RST (reset) pin is connected to pin RD0 (#19)
CE (chip enable) pin is connected to pin RD1 (#20)
DC (data/command) pin is connected to pin RD2 (#21)
DIN (data in)  pin is connected to pin RC7 (#26)
CLK (clock) pin is connected to pin RB1 (#34)

VCC and BL are connected to AMS1117 3V3 regulator output pin and GND is connected to circuit ground (0V).

In this project the PIC18F4550 uses its internal oscillator and MCLR pin function is disabled.

Interfacing PIC18F4550 MCU with NOKIA 5110 LCD C code:
The C code below is for CCS C compiler, it was tested with version 5.051.

To be able to compile project C code, a driver for the Nokia 5110 LCD is required, download link is above. After you download driver file which named NOKIA5110.c, add it to your project folder!

The result of my simple hardware circuit is shown in the following video:

and the video below shows Proteus simulation of the project (note that Proteus simulation circuit is not the same as the real hardware circuit, project hardware circuit diagram is shown above!):

Proteus simulation file download link is below, use version 8.6 or higher to open it:
PIC18F4550 and Nokia 5110 Proteus simulation

Projects where Nokia 5110 LCD is used:
PIC18F4550 Interface with DHT11 sensor and Nokia 5110 LCD
Interfacing PIC18F4550 with Nokia 5110 LCD and DHT22 sensor
Real Time Clock using PIC18F4550, Nokia 5110 LCD and DS1307
Interfacing PIC18F4550 with Nokia 5110 LCD and DS3231 RTC
Digital Thermometer using PIC18F4550, Nokia 5110 LCD and DS18B20
Interfacing PIC18F4550 MCU with BMP280 sensor and Nokia 5110 LCD
Weather Station using PIC18F4550, BME280 Sensor and Nokia 5110 LCD

11 thoughts on “Interfacing PIC18F4550 MCU with NOKIA 5110 LCD”

  1. Leonardo Padovano

    si lo estoy haciendo con el 18f2550 , ahora una consulta estoy haciendo un voltimetro y solo me muestra hasta 4,5 volt que puede ser?

  2. Leonardo Padovano

    si uso el pic 18f2550 podría servirme , necesito un pic mas chico, como declaro los pines en un pic 18f2550

    1. Simple Projects

      You can build this project using microcontroller with at least 1KB of RAM space.
      The PIC16F887 has only 368 bytes.

    1. Simple Projects

      You can not build this project with PIC16F886 MCU because it has very small RAM (only 368 bytes). You need a MCU with at least 1kB of RAM, the PIC18F4550 has 2kB.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top