Beruflich Dokumente
Kultur Dokumente
Dear friends welcome to another tutorial! In this video we are going learn how to build
ourown menu for the popular Nokia 5110 LCD displa...
arduino
electronics
diy
PROJECT INFO
Type
Full instructions provided
Difficulty
Intermediate
Estimated time
1 hour
Published
April 15, 2017
License
GPL3+
949
Rotary Encoder
1
Arduino IDE
STORY
Dear friends welcome to another tutorial! In this video we are going learn how to build
ourown menu for the popular Nokia 5110 LCD display, in order to make our projects more
user friendly and more capable. Lets get started!
This is the project we are going to build. In the display a simple menu appears, and with the
help of the rotary encoder I can navigate up, or down and select a menu item by pressing the
rotary encoder button. When the middle button of the rotary encoder is pressed, another
screen appears and we can change the value of a variable. If we press the rotary encoder
button once more, we go back to the main menu screen. The menu has 6 items, and we can
scroll down or up the menu and the items on the display will change accordingly. Watch the
attached video to see exactly how this menu works. Of course you can modify it to build your
own more complex menus if you wish.
The Nokia 5110 is a basic graphic LCD screen which was originally intended for as a cell
phone screen. It uses the PCD8544 controller which is a low power CMOS LCD
controller/driver. Because of this this display has an impressive power consumption. It uses
only 0.4mA when it is on but the backlight is disable. It uses less than 0.06mA when in sleep
mode! That's one of the reasons that make this display my favorite. The PCD8544 interfaces
to microcontrollers through a serial bus interface. That makes the display very easy to use
with Arduino. You only need to connect 8 wires.
I have prepared a detailed tutorial on how to use the Nokia 5110 LCD display with Arduino. I
have attached that video in this tutorial, it will provide may useful information about the
display, so I encourage you to watch it carefully. The cost of the display is around $4.
The rotary encoder we are going to use in this project is a very inexpensive encoder. It also
has a button embedded and in order to make it work we only need to connect 5 wires. I have
prepared I detailed tutorial on how to use a rotary encoder. You can find this video attached
here.
The cost of this rotary encoder is very low. It costs around $1.5.
I have placed the display on a small breadboard like this. Lets first connect the display. The
first pin of the display which is Reset goes to digital pin 3 of the Arduino Uno, the second pin
goes to digital pin 4, the third pin goes to digital pin 5, the fourth pin to digital pin 11 and the
fifth pin to digital pin 13. The next pin is Vcc. We connect Vcc to the positive rail of the
breadboard, and the breadboard positive rail to the 3.3V output of the Arduino. The next pin is
Backlight for the display. Since we want to control it via the software we connect it to digital
pin 7. The last pin is GND. We connect GND to the negative rail of the breadboard, and the
negative rail of the breadboard to Arduino GND.
Now all we have to do is to connect the rotary encoder. The first pin is GND and we connect
it to negative rail of the breadboard. The next pin is Vcc and we connect it to the positive rail
of the breadboard. The next pin is SW and we connect it to Analog Pin 2. The next pin is
named DT and we connect it to Analog Pin 1. Lastly the pin CLK is connected to Analog Pin
0. You can find the schematic diagram of this project in the description of the video below.
Now we are ready to power up the project. As you can see, the project is working fine, and the
menu is working as expected! Great, lets now see the software of the project.
In this project we use 4 libraries. We use two libraries for the display, and two for the rotary
encoder.
I tried to make the code as easy as possible to modify so I have created some global variables
that hold the names for the menu items. This way, you can create your own menus easily
without searching in code.
Thats the basic idea behind this menu. We follow the same procedure for all the menu items
and pages. The code is complex, it is over 400 lines long. It seems complicated but if you try
it yourself you are going to understand it more easily and you will be able to change it,
expand it and use it in your own projects. As always you can find the code attached here.
Nokia5110MenuRotary.ino
Now that we know how to build menus for the Nokia 5110 LCD displays we can add more
features to our projects and make them more user friendly. This simple menu that we built
today can be improved though. We could use interrupts instead of checking the button states
all the time. This way we can reduce the power consumption of the project and make the code
cleaner. I will prepare a video on interrupts soon so stay tuned. I would love to hear your
opinion about this menu project. Do you find it useful and do you plan to use a menu in any of
your project. Please post your thoughts and ideas below, thanks!
CODE
Code snippet #2Plain text
String menuItem1 = "Contrast";String menuItem2 = "Volume";
String menuItem3 = "Language";
String menuItem4 = "Difficulty";
String menuItem5 = "Light: ON";
String menuItem6 = "Reset";boolean backlight = true;
int contrast=60;
int volume = 50;String language[3] = { "EN", "ES", "EL" };
int selectedLanguage = 0;String difficulty[2] = { "EASY", "HARD" };
int selectedDifficulty = 0;
Github
https://github.com/adafruit/Adafruit-GFX-Library