Project 1 - Interfacing a 16*2 LCD with Arduino using I2C protocol
//Master Code
#include<Wire.h>
void setup()
{
Serial.begin(9600);
Wire.begin();
}
void loop()
{
Wire.beginTransmission(1);
Wire.endTransmission();
delay(100);
}
/*
LiquidCrystal Library
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*/
//Slave code
#include<Wire.h>
#include<LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
void setup()
{
Serial.begin(9600);
Wire.begin(1);
Wire.onReceive(start);
lcd.begin(16,2);
}
void loop()
{
delay(100);
}
void start(int y)
{
lcd.setCursor(0,0);
lcd.print("Total Countries");
lcd.setCursor(6,1);
lcd.print("195");
delay(100);
}