Project 1 - Interfacing a 16*2 LCD with Arduino using I2C protocol
OFFLINE:
#include
void setup()
{
pinMode(A0,INPUT);
Wire.begin();
}
void loop()
{
int x=analogRead(A0);
float value=((x*5)/1024);
int temp=((value-0.5)*100);
Wire.beginTransmission(8);
Wire.write(temp);
Wire.endTransmission();
delay(1000); // Wait for 1000 millisecond(s)
}
#include
#include
LiquidCrystal lcd(12,11,4,5,3,2);
void setup()
{
Serial.begin(9600);
Wire.begin(8);
lcd.begin(16,2);
Wire.onReceive(display);
}
void loop()
{
delay(1000); // Wait for 1000 millisecond(s)
}
void display(int x)
{
int y=Wire.read();
Serial.print(y);
lcd.setCursor(0,0);
lcd.print("the voltage");
lcd.print(y);
lcd.clear();
delay(1000);
}