Project 1 - Interfacing a 16*2 LCD with Arduino using I2C protocol
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2); // set the LCD address to 0x3F for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the LCD
lcd.backlight();
lcd.print("Temperature 1:");
lcd.setCursor(0, 1);
lcd.print("Temperature 2:");
}
void loop()
{
// Read temperature from sensor 1
float temp1 = analogRead(A0) * 0.48828125;
// Read temperature from sensor 2
float temp2 = analogRead(A1) * 0.48828125;
// Print temperatures on LCD
lcd.setCursor(14, 0);
lcd.print(" ");
lcd.setCursor(14, 0);
lcd.print(temp1);
lcd.setCursor(14, 1);
lcd.print(" ");
lcd.setCursor(14, 1);
lcd.print(temp2);
delay(1000);
}