Project 1 - Interfacing a 16*2 LCD with Arduino using I2C protocol
/*1)Interfacing a 16*2 LCD with Arduino using I2C protocol
date: 30/12/2023
Vishnu V Nair*/
#include <LiquidCrystal_I2C.h>
int lcd_Columns= 16; //No of coloumns in LCD
int lcd_Rows= 2; //No of rows in LCD
int I2C_Address= 0x20; //Address of display device
LiquidCrystal_I2C lcd(I2C_Address, lcd_Columns, lcd_Rows); //LCD object with Address, coloumns & rows as parameters
bool messageDisplayed= false;
void setup()
{
lcd.init(); //Initialize the LCD
lcd.backlight(); //Turn on the backlight
}
void loop()
{
//To display message only once
if (!messageDisplayed)
{
lcd.clear(); //Clear display
lcd.setCursor(0, 0); //Set cursor(coloumn, row)
lcd.print("Hello");
lcd.setCursor(0, 1); //Set cursor(coloumn, row)
lcd.print("World");
messageDisplayed = true; //Set the flag true once message is displayed
}
}