Challenge

Project 1 - Interfacing a 16*2 LCD with Arduino using I2C protocol

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 displaying the message on LCD screen.

MATERIAL REQUIRED:

ARDUINO BOARD:2

LCD:2

RESISTOR:2

POTENTIOMETER:2

CONNECTIONS:

LET ARDUINO1->AS MASTER

      ARDUINO2->AS SLAVE

STEP1: INTERFACING BETWEEN MASTER AND LCD (16X2)

  1. LCD OF D4,D5,D6,D8 PINS ARE CONNECTED TO ARDUINO PINS OF 8,9,10,11 RESPECTIVELY.
  2. LCD OF RS(RegisterSelect) and En(Enable) CONNECTED TO ARDUINO PINS OF 2 and 7 RESPECTIVELY.
  3. LCD OF LED Cathode, R/W and VD(VEE) pins CONNECTED TO GROUND.
  4. LCD OF LED Anode and POWER are connected to supply.

STEP2:ARDUINO1 TO ARDUINO2 (OR) IIC (2 WIRE) connection

  1. ARDUINO 1 OF A4 AND A5 PINS CONNECTED TO ARDUINO1 OF A4 AND A5 PIN --> these are SDA(serial data line ) AND SDL(serial clock line) (A4 TO A4 AND A5 TO A5)

STEP3:POTENTIOMETER TO ARDUINO BOARD

  1. POTENTIOMETER HAVE 3 TERMINAL ONE-SUPPLY, TWO-WIPER, THREE-GROUND
  2. LEFT TERMINAL OF THE POTENTIOMETER IS CONNECTED TO THE SUPPLY VOLTAGE(5V) PIN OF THE ARDUINO BOARD. 
  3. MIDDLE TERMINAL OF THE POTENTIOMETER IS CONNECTED TO THE A0 PIN OF THE ARDUINO BOARD 
  4. RIGHT TERMINAL OF THE POTENTIOMETER IS CONNECTED TO THE GROUND PIN OF THE ARDUINO BOARD.

STEP4:COMMON CONNECTION BETWEEN ARDUINO POTENTIOMETER AND LCD

  1. ARDUINO1 AND ARDUINO2 BOARD 5V PIN IS CONNECTED  TO THE  ABOVE AND BELOW +VE TERMINAL OF THE BREAD BOARD .
  2. ARDUINO1 AND ARDUINO2 BOARD GROUND PIN IS CONNECTED  TO THE  ABOVE AND BELOW -VE TERMINAL OF THE BREADBOARD.

CODE FOR ARDUINO1-> MASTER

//master

#include
#include
LiquidCrystal lcd(2,7,8,9,10,11);
void setup()
{
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("LAVANYA");
lcd.setCursor(0,1);
lcd.print("LEARNED LCD LIBRARY");
for(int i=0;i<16>{
lcd.scrollDisplayLeft();
delay(100);
}
//delay(2000);
lcd.clear();

Serial.begin(9600);
Wire.begin();
}
void loop()
{
Wire.requestFrom(8,1);
byte MasterReceive=Wire.read();
int potvalue=analogRead(A0);
byte MasterSend=map(potvalue,0,1023,0,127);
Wire.beginTransmission(8);
Wire.write(MasterSend);
Wire.endTransmission(8);
lcd.setCursor(0,0);
lcd.print("Master");
lcd.setCursor(0,1);
lcd.print("value:");
lcd.print(MasterReceive);
Serial.println("The Master Value is:");
Serial.println(MasterReceive);
delay(500);
lcd.clear();
}

CODE FOR ARDUINO2->SLAVE

//slave
#include
#include
LiquidCrystal lcd(2,7,8,9,10,11);
byte SlaveReceive=0;

void setup()
{
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("LAVANYA");
lcd.setCursor(0,1);
lcd.print("LEARNED I2C PROTOCOL");
for(int i=0;i<16>{
lcd.scrollDisplayLeft();
delay(100);
}
//delay(5000);
lcd.clear();

Serial.begin(9600);
Wire.begin(8);
Wire.onReceive(receiveEvent);
Wire.onRequest(requestEvent);

}

void loop()
{
lcd.setCursor(0,0);
lcd.print("Slave");
lcd.setCursor(0,1);
lcd.print("value:");
Serial.println("The Slave Value is:");
Serial.println(SlaveReceive);
lcd.print(SlaveReceive);
delay(500);
lcd.clear();
}

void receiveEvent(int howmany)
{
SlaveReceive =Wire.read();

}
void requestEvent()
{
int potvalue=analogRead(A0);
byte SlaveSend=map(potvalue,0,1023,0,127);
Wire.write(SlaveSend);
}

OUTPUT:1:vary Slave Arduino potentiometer to get results at Master Arduino lcd(received data from slave  to master)

OUTPUT:2: vary master Arduino potentiometer to get results at slave Arduino lcd(received data from master to slave )  

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.