Arduino Nokia 5110 LCD Tutorial #1 - Connecting and Initial Programming

Channel: Julian Ilett


TIP: Right-click and select "Save link as.." to download video

Initializing link download... Initializing link download.....

Detailed tutorial on connecting and programming the Nokia 5110 LCD. In this first part I'm only concerned with sending the bare minimum of commands so that something appears on the screen (all pixels on in this case).
Code is written from scratch, no libraries are used in this tutorial. Code is listed below.

#define RST 12
#define CE 11
#define DC 10
#define DIN 9
#define CLK 8

void LcdWriteCmd(byte cmd)
digitalWrite(DC, LOW); //DC pin is low for commands
digitalWrite(CE, LOW);
shiftOut(DIN, CLK, MSBFIRST, cmd); //transmit serial data
digitalWrite(CE, HIGH);

void setup()
pinMode(RST, OUTPUT);
pinMode(CE, OUTPUT);
pinMode(DC, OUTPUT);
pinMode(DIN, OUTPUT);
pinMode(CLK, OUTPUT);
digitalWrite(RST, LOW);
digitalWrite(RST, HIGH);

LcdWriteCmd(0x21); // LCD extended commands
LcdWriteCmd(0xB8); // set LCD Vop (contrast)
LcdWriteCmd(0x04); // set temp coefficent
LcdWriteCmd(0x14); // LCD bias mode 1:40
LcdWriteCmd(0x20); // LCD basic commands
LcdWriteCmd(0x09); // LCD all segments on

void loop()