Project 1 - Interfacing a 16*2 LCD with Arduino using I2C protocol
Project : implementing the Code for “Interfacing a 16*2 LCD with two Arduino’s (one for Master and one for Slave) using Inter-Integrated Circuit (I2C) communication protocol” by sending the message to LCD using I2C communication protocol and display the message on LCD screen.
#include <wire.h> / for I2c communication function\
#include<LiquidCrystal.h> / LCD library function\
LiquidCrystal lcd(13,12,5,4,3,2); / digital pins of aurdino\
void setup()
{
Serial.begin(9600); /serial communication 9600 baud rate\
lcd.begin(16,2); / lcd Intialisation\
Wire.begin(1); /begin I2c communication at fin A4&A5\
Wire.onReceive(myfunction);
}
void myfunction(int p)
{
int a=Wire.read();
lcd.setCursor(4,0); / set cursor at 4th place in Lcd\
lcd.print(a); / Required data print\
delay(500);
}
void loop()
{
}
b) code
#include <wire.h>
void setup()
{
Serial.begin(9600);
Serial.println("master"); /help to print console PC\
Wire.begin();
}
void loop()
{
int mydata=18;
Wire.beginTransmission(1);
Wire.write(mydata);
Wire.endTransmission();
}
https://www.tinkercad.com/things/8S7y1QI2uoQ-ingenious-jaban-bruticus/editel?sharecode=CVV-ziAF9N-3H3NRFxzLTAVUuFZI-hC6LoJ3CpXqM4M