Skip to content

Instantly share code, notes, and snippets.

@elktros
Created February 27, 2021 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elktros/f64877fdb71f15101845c99007ca4b26 to your computer and use it in GitHub Desktop.
Save elktros/f64877fdb71f15101845c99007ca4b26 to your computer and use it in GitHub Desktop.
Displaying simple text on Nokia 5110 LCD using ESP32.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>
/* Declare LCD object for SPI
Adafruit_PCD8544(CLK,DIN,D/C,CE,RST); */
Adafruit_PCD8544 display = Adafruit_PCD8544(18, 23, 4, 15, 2);
int contrastValue = 60; // Default Contrast Value
const int adcPin = 34;
int adcValue = 0;
void setup()
{
/* Initialize the Display*/
display.begin();
/* Change the contrast using the following API*/
display.setContrast(contrastValue);
/* Clear the buffer */
display.clearDisplay();
display.display();
delay(1000);
/* Now let us display some text */
display.setTextColor(WHITE, BLACK);
display.setCursor(0,1);
display.setTextSize(2);
display.println("|ESP32|");
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(22,20);
display.println("|Nokia|");
display.setCursor(22,32);
display.println("|5110|");
display.display();
delay(2000);
}
void loop()
{
/* You can implement your own display logic here*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment