Arduino Code for a Nokia 5110 LCD Screen
In this tutorial, we will explore how to use the Nokia 5110 LCD screen with an Arduino to display various graphics and text. The project will demonstrate how to draw lines, circles, rectangles, and even display text inside those shapes. By the end, you'll have a better understanding of how to interact with this LCD using Arduino code.

To provide clearer guidance, I encourage you to watch the associated video for a visual representation of the wiring and code implementation (in video at 00:00).
Hardware Explained
The Nokia 5110 LCD is a compact graphical display that operates on the SPI protocol, enabling efficient communication with the Arduino. It features a resolution of 84x48 pixels, which is sufficient for displaying basic graphics and text. The display requires only a few pins to operate, making it a great choice for projects with limited I/O options.
In addition to the LCD, you will need an Arduino board, typically an Arduino Uno or similar, a breadboard, and some jumper wires. The wiring is straightforward, and the LCD is powered by connecting its VCC pin to the Arduino's 5V output.
Datasheet Details
| Manufacturer | Philips |
|---|---|
| Part number | PCD8544 |
| Logic/IO voltage | 3.3 V |
| Supply voltage | 3.3 – 5.0 V |
| Max current | 200 µA |
| Screen resolution | 84 x 48 pixels |
| Interface | Serial (SPI) |
| Package | Module |
- Use a current-limiting resistor for the LED pin to prevent damage.
- Ensure connections to VCC and GND are secure to avoid display issues.
- Double-check SPI pin connections: SCE, RST, D/C, DN, and SCLK.
- Keep the contrast setting within the recommended range (40-60).
- Update the display after drawing graphics to see changes.
Wiring Instructions

To wire the Nokia 5110 LCD to your Arduino, follow these connections:
- Connect the LCD's
VCCpin to the Arduino's5Vpin. - Connect the
GNDpin on the LCD to one of the Arduino'sGNDpins. - Connect the
SCEpin on the LCD to pin7on the Arduino. - Connect the
RSTpin to pin6. - Connect the
D/Cpin to pin5. - Connect the
DN (MOSI)pin to pin11. - Connect the
SCLKpin to pin13. - Finally, connect the
LEDpin to pin9through a 330-ohm resistor.
These connections will allow the Arduino to communicate with the LCD effectively. If you need to adjust the wiring for your specific setup, ensure that the SPI pins remain consistent.
Code Examples & Walkthrough
The following code snippet initializes the LCD and sets the contrast:
void setup() {
Serial.begin(9600);
lcdBegin(); // Initialize the LCD
setContrast(40); // Set contrast level
delay(2000);
clearDisplay(BLACK); // Clear the display
updateDisplay(); // Update the display
}
In this snippet, the lcdBegin() function sets up the necessary pins for the LCD, while setContrast(40) adjusts the display's contrast. After a brief delay, the display is cleared to prepare for new content.

Next, we can draw a line on the display:
setLine(1, 4, 70, 4, BLACK); // Draw a horizontal line
updateDisplay(); // Make the line visible
This line of code uses the setLine() function, which takes the starting and ending coordinates along with a color parameter. After drawing, it's essential to call updateDisplay() to reflect the changes on the screen.
Finally, we can display text within a rectangle:
setRect(10, 10, 70, 40, 1, BLACK); // Draw a filled rectangle
setStr("Robojax ", 15, 20, WHITE); // Display text inside
updateDisplay(); // Update to show the changes
Here, setRect() creates a rectangle, while setStr() places text inside it. The color parameters define how the rectangle and text appear on the screen.
Demonstration / What to Expect
Upon running the code, you should see a series of graphics displayed on the Nokia 5110 LCD, including lines, circles, rectangles, and text. Ensure your wiring is correct to avoid issues like reversed polarity or floating inputs, which could prevent the display from functioning (in video at 02:30).
Video Timestamps
- 00:00 - Introduction to the project
- 01:30 - Wiring instructions
- 03:00 - Code setup and explanation
- 05:00 - Displaying graphics and text
- 07:30 - Conclusion and further modifications
Things you might need
-
Amazon
-
AmazonPurchase XY Joystick from Amazonamzn.to
Resources & references
No resources yet.
Files📁
Fritzing File
-
Nokia 5110 LCD
application/zip0.03 MB -
Black Joystick KY-023
application/zip0.02 MB