We have received a number of requests for examples on how to use our Nokia 5110 with Arduino - so here it goes. For this tip we used a Arduino Nano, but any Arduino can be used.
What we want to achieve
Use our Nokia 5110 displays - which feature a PCD8544 CMOS LCD controller/driver - with an Arduino (compatible) development board and the Arduino IDE.
Requirements
- Arduino (compatible) development board - we used the Arduino Nano compatible board (see here)
- Our Nokia 5110 Display featuring a PCD8544 controller (see here)
- Arduino IDE (download here)
Restrictions
- This tip is focused on using the Arduino IDE
- The pin connections are guaranteed to work with our Nokia 5110 displays. Other similar displays might have a different pin layout and you will need to adapt to your specific module.
- We will be using Gavin Lyons' "Nokia 5110 Text" Library which is available through the Arduino IDE Library Manager. There are other options, this one is the easiest (we found).
Credits
- Gavin Lyons - Nokia 5110 Text Library - https://github.com/gavinlyonsrepo/NOKIA5110_TEXT
How to
... Install required Library
Gavin Lyons created a great library with a small memory footprint to display text on PCD8544 based Nokia 5110 8-pin displays.
You can install the library through the Library Manager:
Menu -> Tools -> Manage Libraries
... Output Text to Display
For this project we are not using Pin 7 (Backlight) and have used the wiring as below.
Wiring
PCD8544/LED | Arduino |
Pin 1 - RST | D12 |
Pin 2 - CE (CS) | D11 |
Pin 3 - DC | D10 |
Pin 4 - DIN | D9 |
Pin 5 - CLK | D8 |
Pin 6 - VCC | 3.3V - either from Development board or other sources |
Pin 7 - BL | Not used in this example |
Pin 8 - GND | GND - either from Development board or another source |
Code
//
// Nokia 5110 LED with PCD8544 for Arduino
// 5 January 2020
// Author: Gavin Lyons
// Modified for pin layout: dante@serveronthemove.com.au
// Hardware:
// Arduino
// 8 pin Nokia 5110 84x48 display w PCD8544
//
// Wiring:
// Nokia 5110 -> Arduino
// 1 - RST -> D12
// 2 - CE (CS) -> D11
// 3 - DC -> D10
// 4 - DIN -> D9
// 5 - CLK -> D8
// 6 - VCC -> 3.3V
// 7 - BL -> Not used in this example
// 8 - GND -> GND
//
//LCD Nokia 5110 pinout left to right
// RST 1/ CD 2/ DC 3/ DIN 4/ CLK 5
NOKIA5110_TEXT mylcd(12, 11, 10, 9, 8);
#define mydelay 1000
void setup() {
mylcd.LCDInit(); //init the lCD
mylcd.LCDClear(); //clear whole screen
//mylcd.LCDsetContrast(0xB1); // default is 0xBF set in init
}
void loop() {
delay(mydelay);
mylcd.LCDgotoXY(0,0); // (go to (X , Y) (0-84 columns, 0-5 blocks)
mylcd.LCDString("Block 0"); //print to block 0 (0-5 blocks or row bytes)
delay(mydelay);
mylcd.LCDgotoXY(4,5);
mylcd.LCDString("Block 5"); //print to block 5 indented by 4 col
delay(mydelay);
mylcd.LCDClearBlock(0); //clear line/block 1
delay(mydelay);
mylcd.LCDClearBlock(5); //clear line 5
delay(mydelay);
mylcd.LCDenableSleep(); //goto sleep
delay(mydelay);
delay(mydelay);
mylcd.LCDdisableSleep(); //wake up
delay(mydelay);
}