Project 1 - Interfacing a 16*2 LCD with Arduino using I2C protocol
Overview of the Project:
In this 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.
Goals:
- Communication between Arduino and 16*2 LCD using I2C protocol.
- Displaying the message sent by Master and received by slave i.e. LCD display.
Key Highlights of the Project:
- Using the inter-integrated circuit communication protocol, transferring the data i.e. the message we want to display is sent to the LCD.
- Two Arduino’s connected to the LCD display and the communication is executed using I2C protocol between Arduino and the LDC display.
Deliverables of this project:
- Communication between the Arduino’s and LCD using I2C.
- The message passed from master to slave and displayed on the 16*2 LCD.
Expected Outcomes:
- Students will get the Knowledge of I2C communication Protocol and the Arduino.
- The Hardware connection of all components used in this project.
- Displaying the message sent by master (Arduino) and received by the slave (16*2 LCD display).
......................................................................................................................................................................................................
MASTER CODE:-
//MASTER
#include<Wire.h> //this is I2C header file
void setup()
{
pinMode(A1, INPUT); //A1 is INPUT pin
Wire.begin(); // this wire.begin starts communication
}
void loop()
{
float value=analogRead(A1); //analogread the A1 value
signed int voltage=(value*5)/1024;//analog to digital
Wire.beginTransmission(5); //Transmission of data starting
Wire.write(voltage); // digital value writing
Wire.endTransmission(); //Transmission end
delay(500);
}
SLAVE CODE:-
//SLAVE
#include<Wire.h> //I2C header file
#include<LiquidCrystal.h> // LCD header file
LiquidCrystal lcd(12,11,5,4,3,2);//lcd pins
void setup()
{
lcd.begin(16,2);//lcd started when we give the thi line
lcd.setCursor(0,0);//Cursor in first line first position
lcd.print(" RECEIVING DATA"); // this comes in lcd first line
lcd.setCursor(1,1);//lcd second line second position
lcd.print(" FROM MASTER");//this comes in second line
delay(2000);//delay of 2000ms
lcd.clear();//after the delay lcd clear the all DATA
Wire.begin(5);
Wire.onReceive(receive);//RECEIVING the DATA from master
lcd.begin(16,2);
}
void loop()
{
delay(500);//delay 500ms
}
void receive(int i)
{
signed int voltage=Wire.read();
lcd.setCursor(0,0);
lcd.print("MASTER ->> SLAVE");
lcd.setCursor(1,1);
lcd.print(" VOLTAGE:-");
lcd.print(voltage);
delay(500);
}
.................................................................................................................................................................................................
OUTPUTS:-



