Nokia 5110 LCD

The 84x48 screen out of the Nokia 5110 and 3310 phones, on a small board with eight pins. Aliases: Nokia 5110, PCD8544, 84x48 LCD.

It is a reflective LCD: dark ink on a gray-green glass, readable with the backlight off, and cheap enough that every kit had one for a while.

Pins

Pin What it does
RST Reset, active low.
CE Chip enable, active low.
DC Low for a command, high for pixels.
DIN Serial data in.
CLK Serial clock.
VCC Supply, 3.3 V.
LIGHT The backlight: driven high, it lights.
GND Ground.

Properties

None.

What the model gets right

The bus. Serial, MSB first, DIN sampled on the rising edge of CLK while CE is low, and DC read with the eighth bit. CE going high throws away a byte cut short. There is no data out: nothing can be read back, on the bench or here.

The two instruction sets. The function set (0x20 to 0x27) picks power-down, vertical addressing and the extended set. In the basic set there are display control (blank, normal, all on, inverse) and the X and Y address; in the extended set there are the temperature coefficient, the bias and Vop.

The RAM. Six banks of 84 bytes. A byte is eight pixels stacked down the glass, bit 0 at the top. The address steps along X and wraps into the next bank, or with vertical addressing down the banks and into the next column, and wraps round the whole RAM at the end, so 504 bytes after 0x40 0x80 is a full screen.

Contrast is Vop. Below about 20 nothing shows at all; from there the ink darkens as Vop rises. A sketch that never sets it sees an empty glass, which is the first thing that goes wrong with a real one.

Reset. RST low puts the chip in its reset state: powered down, display blank, Vop 0. The RAM keeps what it had.

What it does not model

Past about 90, a real panel darkens its background too until nothing can be read; here the ink just stays at its darkest. The chip's state before its first reset is undefined on the bench; here it starts in the reset state. Temperature and bias change nothing. The red boards, whose backlight lights when LIGHT is pulled low, are not modeled: this is the blue board's wiring.

Code

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

// CLK, DIN, DC, CE, RST
Adafruit_PCD8544 display(7, 6, 5, 4, 3);

void setup() {
  display.begin();
  display.setContrast(50);
  display.clearDisplay();
  display.setTextColor(BLACK);
  display.setCursor(0, 0);
  display.println("Nokia 5110");
  display.drawRect(0, 12, 84, 36, BLACK);
  display.display();
}

void loop() {}

Adafruit_PCD8544.h is Mokxi's own, on the same calls as upstream. It keeps the picture in 504 bytes of the board's RAM and display() sends the banks that changed.

Common mistakes

Never setting the contrast, or setting it far too high. Forgetting display() after drawing: the picture is in the board's RAM and not on the glass. Running it from 5 V logic: the chip is a 3.3 V part, which the simulation does not mind and the bench might.

See it in action

Three small screens at /templates starts a Nokia 5110 by hand, Vop and all, beside two OLEDs, with LIGHT on a pin the sketch sets high.