Introduction
Nokia5110 Display
Nokia5110 is a graphical display that can display text, images and various patterns.
It has a resolution of 48x84 and comes with a backlight.
It uses SPI communication to communicate with a microcontroller.
Data and commands can be sent through microcontroller to the display to control the display output.
It has 8 pins.
For more information about Nokia5110 display and how to use it, refer the topic Nokia5110 Graphical Display in the sensors and modules section.
Interfacing Diagram
Interfacing Nokia5110 Module WithParticle Photon
Example
Displaying text, rectangular, circle, line, images etc. on Nokia5110 display.
Here, we will be using nokia-5110-lcdlibrary from Particle Library.
There is very small change in this developed library to work. To make the changes to the nokia-5110-lcd library we have to edit that library. But these existing libraries are readable only.
So, to make changes follow the steps given below to add and change the library.
1. Go to web or Desktop IDE
2. Create a new APP.
3. Copy the code given below and paste it in the ino file that you created in the new APP.
4. Now click on create a new library and give the name nokia-5110-lcd.
5. Now Click on Library Icon.
6. Type nokia-5110-lcd and click on that and open it.
7. Copy the code from nokia-5110-lcd.cpp and nokia-5110-lcd.h and paste inthe respective library files you created in step 4.
8. Click on nokia-5110-lcd.cppin your library, and add SPI.setClockSpeed(4, MHZ); after SPI.begin();asshown in figure below
9. Now compile and flash it on your photon board.
Sketch for Nokia5110 Display
/* display image and string on Nokia5110 using Particle Photon
http://wwww.electronicwings.com
*/
#include "nokia-5110-lcd.h"
#include "particle_logo.h"
Nokia5110LCD::Display nokiaLCD(D0, D1, D2, A0); //_pinSCE, _pinRESET, _pinDC, _pinBL, _pinSDIN, _pinSCLK
void setup()
{
nokiaLCD.begin(); // This will setup our pins, and initialize the LCD
nokiaLCD.setContrast(28); // Pretty good value, play around with it
/* Display Image logo of particle stored in particle.h*/
nokiaLCD.gotoXY(0, 0);
for (int h = 0; h < 504; h++) {
nokiaLCD.write(LCD_DATA, particleimg[h]);
}
delay(3000);
nokiaLCD.clearDisplay(WHITE);
}
void loop()
{
/*Draw a rectangle */
nokiaLCD.setRect(4, 4, 80, 44, 0, BLACK);
nokiaLCD.updateDisplay();
/* Display a string */
nokiaLCD.setStr("Welcome", 25, 10, BLACK);
nokiaLCD.setStr("To", 40, 20, BLACK);
nokiaLCD.setStr("EW", 40, 32, BLACK);
nokiaLCD.updateDisplay();
delay(1000);
nokiaLCD.clearDisplay(WHITE);
/* Draw a rectangle in inverse mode */
nokiaLCD.setRect(4, 4, 80, 44, 1, BLACK);
nokiaLCD.updateDisplay();
/* Display a string in inverse mode */
nokiaLCD.setStr("Welcome", 25, 10, WHITE);
nokiaLCD.setStr("To", 40, 20, WHITE);
nokiaLCD.setStr("EW", 40, 32, WHITE);
nokiaLCD.updateDisplay();
delay(1000);
nokiaLCD.clearDisplay(WHITE);
}
Components Used |
||
---|---|---|
Particle Photon PHNTRAYH |
X 1 | |
Nokia5110 Graphical Display Nokia5110 is 48x84 dot LCD display with Serial Peripheral Interface (SPI) Connectivity. It was designed for cell phones. It is also used in embedded applications. |
X 1 |