/*
Project: LCD Demo
Description: Basic connections and setups for
parallel and I2c LCD displays.
Creation date: 7/3/23
Author: AnonEngineering
Added 20x4 6/25/25
*/
// for this demo, include libraries for both types of LCD
#include <LiquidCrystal.h>
#include <LiquidCrystal_I2C.h>
// pin constants for the parallel LCD
const int RS = 12, EN = 11, D4 = 10, D5 = 9, D6 = 8, D7 = 7;
// create a parallel LCD object called "lcd"
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7);
// create I2C LCD objects with different names and sizes
LiquidCrystal_I2C lcdI2C_16x2(0x27, 16, 2);
LiquidCrystal_I2C lcdI2C_20x4(0x28, 20, 4); // different address
void setup() {
// start serial
Serial.begin(115200);
// start parallel LCD
lcd.begin(16, 2); // or (20, 4)
// start 16x2 I2C LCD
lcdI2C_16x2.init();
// turn on the I2C LCD backlight
lcdI2C_16x2.backlight();
// start 20x4 I2C LCD
lcdI2C_20x4.init();
// turn on the I2C LCD backlight
lcdI2C_20x4.backlight();
// start up message on parallel LCD
lcd.setCursor(2, 0);
lcd.print("Parallel LCD");
lcd.setCursor(1, 1);
lcd.print("Uses 6 uC pins");
// start up message on 16x2 I2C LCD
lcdI2C_16x2.setCursor(2, 0);
lcdI2C_16x2.print("16x2 I2C LCD");
lcdI2C_16x2.setCursor(1, 1);
lcdI2C_16x2.print("Uses 2 uC pins");
// start up message on 20x4 I2C LCD
lcdI2C_20x4.setCursor(4, 0);
lcdI2C_20x4.print("20x4 I2C LCD");
lcdI2C_20x4.setCursor(0, 1);
lcdI2C_20x4.print("Also uses 2 uC pins,");
lcdI2C_20x4.setCursor(0, 2);
lcdI2C_20x4.print("but has 4 rows (0-3)");
lcdI2C_20x4.setCursor(0, 3);
lcdI2C_20x4.print("and twenty columns!");
}
void loop() {
// nothing to loop about...
}