You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains a custom lcd driver for 16x02 lcd. The driver has the most common function calls
that are use for LCDs. ESP32 have limited GPIO pins, therefore 4-bit mode was use as it requires a total of 6GPIO pins. However, there are two configurations for the driver: default and custom. The default configurations uses this pinout while the custom allows the user to select whichever GPIO are avaiable simple by using lcdCtor().
The following pinout is the default configuration of the ESP-LCD driver. However, the driver
is customizable to allow users to change GPIO pins if necessary.
ESP32 Pins
LCD Pin
Description
GND, 10k Potentiometer Output (V±)
1
GND
VCC, 10k Potentiometer Output (V±)
2
VCC
10k Potentiometer Output (Vo)
3
Contrast
GPIO23
4
RS (Register Select): 0–Command, 1-Data
GND
5
R/W (Read/Write): 0 – Write, 1 - Read
GPIO22
6
Clock Enable
NC
7
Data 0
NC
8
Data 1
NC
9
Data 2
NC
10
Data 3
GPIO19
11
Data 4
GPIO18
12
Data 5
GPIO17
13
Data 6
GPIO16
14
Data 7
100Ω to VCC
15
Backlight Anode (+)
GND
16
Backlight Cathode (-)
LCD default pin configuration
LCD Main Functions
Function
Description
lcdDefault
Default pinout
lcdCtor
Customizable pinout constructor
lcdSetText
Set text
lcdSetInt
Set integer
lcdClear
Clear previous data
lcdFree
Free LCD pins
assert_lcd
Check lcd status
Simple Example Code
The follow section of code demostrate how to use the lcd driver with default configuration.
#include<stdio.h>#include"freertos/FreeRTOS.h"#include"freertos/task.h"#include"driver/esp_lcd.h"/* LCD task */voidlcd_task(void*pvParameters){
/* Create LCD object */lcd_tlcd;
/* Set lcd to default pins */lcdDefault(&lcd);
/* Initialize LCD object */lcdInit(&lcd);
/* Clear previous data on LCD */lcdClear(&lcd);
while(1){
/* Display text */lcdSetText(&lcd,"Hello World!", 0,0);
/* 1 second delay */vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
voidapp_main(void)
{
/* Create LCD task */xTaskCreate(lcd_task, "LCD task", 2048, NULL, 4, NULL);
}