Home ARDUINO How to Drive and Build Project with Nokia 5110 LCD using Arduino

How to Drive and Build Project with Nokia 5110 LCD using Arduino

0
How to Drive and Build Project with Nokia 5110 LCD using Arduino
Build Project with Nokia 5110 LCD using Arduino

How to Drive and Build Project with Nokia 5110 LCD using Arduino

In this article, I will guide you how to create a menu on the Nokia 5110 LCD. Today we are using Arduino Uno, but you can use any Arduino you like. Let’s get started with the Arduino Nokia 5110 Menu Tutorial. This article is intended to provide a complete guide to Arduino’s Nokia 5110 LCD. I will explain what it does, show its specifications, and share an example of an Arduino project that you can apply to your own project.

How to Drive and Build Project with Nokia 5110 LCD using Arduino

This is the project we want to build. A simple menu appears on the display, with the help of three buttons, I can navigate up and down and select a menu item. We choose the first option. As you can see, a new UI screen is displayed and by pressing the up and down buttons we can change the contrast of the display. If we press the middle button again, we return to the main UI screen. If we now select the second menu item and press the middle button, we can turn the monitor’s backlight on or off. Finally, if we navigate to the last menu item, we can reset the display settings to their defaults. Of course, this is just a demo project, and you can modify it to create your own more complex menus if you prefer. Now let’s see how to set up this project.

Why Nokia 5110

How to Drive and Build Project with Nokia 5110 LCD using Arduino

The Nokia 5110 LCD is very popular with dimmers in Arduino. These modules are used for a variety of applications that require some kind of interface or display data to the user.

So Let’s Get Started to Build Project with Nokia 5110 LCD using Arduino

Collect Hardware

Arduino UNO (Buy Amazon)

Nokia 5110 LCD (Buy Amazon)

Small Breadboard (Buy Amazon)

Buttons (Buy Amazon)

Jumper Wires  (Buy Amazon)

Make Connection

LCD                                 Arduino

Pin1—————————3
Pin2—————————4

Pin3—————————5

Pin4—————————11

Pin5—————————13

Pin6—————————3.3v

Pin7—————————7

Pin8—————————GND

Buttons               Arduino

1st Button ————-1
2nd Button————-2

3rd Button————-3

Software Requirements

Download Libraries

Adafruit GFX: https://github.com/adafruit/Adafruit-GFX-Library

Nokia 5110: https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library

In this project, we use two libraries to show Adafruit. You can find a link between the two in the video’s description. First, let’s take a look at the drawMenu function. This function is responsible for drawing the menu on the display. This function is called every few milliseconds, so if the menu changes, this function is responsible for updating the menu on the screen. There are two very important global variables, variable pages and variables menuitem. The variable page remembers which UI screen to display on the screen. So, if the page variable is 1, we are on the main UI screen, and if the variable is 2, we are comparing the UI screen. The menu item remembers the selected menu item. So, if its value is 1, then the first menu item is selected, so the drawMenu function must draw this menu item in white with white letters. If the menu item is 2, select the second menu item and so on.

Note: if you are beginner in Arduino then please have a look at my previous article “Beginner guide for Arduino

Upload Source Code 

#include <Adafruit_GFX.h>

#include <Adafruit_PCD8544.h>

 

boolean backlight = true;

int contrast=50;

 

int menuitem = 1;

int page = 1;

 

volatile boolean up = false;

volatile boolean down = false;

volatile boolean middle = false;

 

int downButtonState = 0;

int upButtonState = 0;

int selectButtonState = 0;

int lastDownButtonState = 0;

int lastSelectButtonState = 0;

int lastUpButtonState = 0;

 

Adafruit_PCD8544 display = Adafruit_PCD8544( 5, 4, 3);

 

void setup() {

 

pinMode(2, INPUT_PULLUP);

pinMode(1, INPUT_PULLUP);

pinMode(0, INPUT_PULLUP);

pinMode(7,OUTPUT);

 

digitalWrite(7,LOW); //Turn Backlight ON

 

Serial.begin(9600);

 

display.begin();

display.setContrast(contrast); //Set contrast to 50

display.clearDisplay();

display.display();

}

 

void loop() {

 

drawMenu();

 

downButtonState = digitalRead(2);

selectButtonState = digitalRead(1);

upButtonState =   digitalRead(0);

 

checkIfDownButtonIsPressed();

checkIfUpButtonIsPressed();

checkIfSelectButtonIsPressed();

 

if (up && page == 1 ) {

up = false;

menuitem–;

if (menuitem==0)

{

menuitem=3;

}

}else if (up && page == 2 ) {

up = false;

contrast–;

setContrast();

}

 

 

if (down && page == 1) {

down = false;

menuitem++;

if (menuitem==4)

{

menuitem=1;

}

}else if (down && page == 2 ) {

down = false;

contrast++;

setContrast();

}

 

 

if (middle) {

middle = false;

 

if (page == 1 && menuitem==2)

{

if (backlight)

{

backlight = false;

turnBacklightOff();

}

else

{

backlight = true;

turnBacklightOn();

}

}

 

if(page == 1 && menuitem ==3)

{

resetDefaults();

}

 

 

else if (page == 1 && menuitem==1) {

page=2;

}

else if (page == 2) {

page=1;

}

}

 

}

 

void checkIfDownButtonIsPressed()

{

if (downButtonState != lastDownButtonState)

{

if (downButtonState == 0)

{

down=true;

}

delay(50);

}

lastDownButtonState = downButtonState;

}

 

void checkIfUpButtonIsPressed()

{

if (upButtonState != lastUpButtonState)

{

if (upButtonState == 0) {

up=true;

}

delay(50);

}

lastUpButtonState = upButtonState;

}

 

void checkIfSelectButtonIsPressed()

{

if (selectButtonState != lastSelectButtonState)

{

if (selectButtonState == 0) {

middle=true;

}

delay(50);

}

lastSelectButtonState = selectButtonState;

}

 

 

void drawMenu()

{

 

if (page==1)

{

display.setTextSize(1);

display.clearDisplay();

display.setTextColor(BLACK, WHITE);

display.setCursor(15, 0);

display.print(“MAIN MENU”);

display.drawFastHLine(0,10,83,BLACK);

display.setCursor(0, 15);

 

if (menuitem==1)

{

display.setTextColor(WHITE, BLACK);

}

else

{

display.setTextColor(BLACK, WHITE);

}

display.print(“>Contrast”);

display.setCursor(0, 25);

 

if (menuitem==2)

{

display.setTextColor(WHITE, BLACK);

}

else

{

display.setTextColor(BLACK, WHITE);

}

display.print(“>Light: “);

 

if (backlight)

{

display.print(“ON”);

}

else

{

display.print(“OFF”);

}

display.display();

 

if (menuitem==3)

{

display.setTextColor(WHITE, BLACK);

}

else

{

display.setTextColor(BLACK, WHITE);

}

display.setCursor(0, 35);

display.print(“>Reset”);

display.display();

}

 

 

else if (page==2)

{

 

display.setTextSize(1);

display.clearDisplay();

display.setTextColor(BLACK, WHITE);

display.setCursor(15, 0);

display.print(“CONTRAST”);

display.drawFastHLine(0,10,83,BLACK);

display.setCursor(5, 15);

display.print(“Value”);

display.setTextSize(2);

display.setCursor(5, 25);

display.print(contrast);

 

display.setTextSize(2);

display.display();

}

 

}

 

void resetDefaults()

{

contrast = 50;

setContrast();

backlight = true;

turnBacklightOn();

}

 

void setContrast()

{

display.setContrast(contrast);

display.display();

}

 

void turnBacklightOn()

{

digitalWrite(7,LOW);

}

 

void turnBacklightOff()

{

digitalWrite(7,HIGH);

}

TEST Video

 

NOTE If you face any problem regarding this project then please write comment below


Visit similar projects tutorials on Raspberry Pi and Arduino

How to Build your own Super Computer with Raspberry Pi 3 Cluster

Build Super Computer with 5$ Raspberry pi zero using Cluster HAT

How to make a Raspberry Pi bitcoin mining rig

Convert Any Printer into a Wireless Printer with a Raspberry Pi zero (10$ Cost)
Build AYI Google Voice Home with Raspberry Pi Under 35$

Best Raspberry Pi Alternatives ( Updated 2018 List)

 

Advertisements

LEAVE A REPLY

Please enter your comment!
Please enter your name here

seventeen + sixteen =