Project 1 - Interfacing a 16*2 LCD with Arduino using I2C protocol
Aim:
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).
Solutions:
Master Code :
//MASTER
#include<Wire.h>//Wire library for using I2C communication functions
void setup()
{
pinMode(A1, INPUT);//set the input value at A1 pin
Serial.begin(9600);//set the baud rate
Wire.begin();//begin i2c communication
}
void loop()
{
float value=analogRead(A1);//read the analog value
Serial.println(value);//print the analog value in serial monitor
signed int voltage=(value*5)/1024;//analog adc value convert into voltage
// int temp=(voltage-0.5)*100;
Wire.beginTransmission(1);// start transmit to slave arduino
Wire.write(voltage);// sends one byte converted POT value to slave
Wire.endTransmission();// stop transmitting
delay(50);
}
Slave Code :
//SLAVE
#include<Wire.h>//Wire library for using I2C communication functions
#include<LiquidCrystal.h>//LCD library for using LCD functions
LiquidCrystal lcd(12,11,5,4,3,2);//select RW,Enable,DB4,DB5,DB6,DB7 pin
void setup()
{
Serial.begin(9600);//set the baudrate
Wire.begin(1);//Begins I2C communication at pin (SDA,SCL)
Wire.onReceive(uno);//receive from master potential value
lcd.begin(16,2);//initialize the lcd display
}
void loop()
{
delay(50);//delay 50 milliseconds
}
void uno(int w)
{
signed int voltage=Wire.read();//read the master pot value
lcd.setCursor(0,0);//set the lcd cursor position 1 st line of display
lcd.print("the voltage is");//print the text in lcd display
lcd.setCursor(0,1);//set the lcd cursor position 2nd line of display
lcd.print(voltage);//print the voltage in lcd
Serial.print("voltage value\n");//print the text in serial monitor
Serial.println(voltage);//print the voltage value in serial monitor
delay(50);//delay 50 milliseconds
}
CIRCUIT DIAGRAM :
Before Simulation

After Simulation
we have to display the input pot value in serial monitor

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.
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 at below the image.

we vary the input value in master and receive the output in slave device,output display in lcd display.
