Challenge

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

Here our total circuit which represent the I2C protocol circuit 16x2 display which connected with slave device and we connecte the master device by two ware connection protocol here the master device adress is "1" and we give the command "w" to the slave device and we print the command in display unit by the slave controller.

Here is our controller program for slave device and master device.

The logic is very simple we use "Wire.h" heder file for configuring the I2C protocol and we use "LiquidCrystal_I2C.h" for displing the command come from the master device .

We use the brod rate 9600.

Master device adress as "1"

display device adress is 32.

/*............................Slave code...............................*/


#include 
#include 
LiquidCrystal_I2C lcd(32,16,2);

void setup()
{ 
  lcd.begin(16,2);
  lcd.init();
  lcd.backlight();
  Serial.begin(9600);
  Wire.begin();
  lcd.setCursor(0,0);
}

void loop()
{ 
        lcd.setCursor(0,0);
        Wire.requestFrom(1,4);        
        char r=Wire.read();
        lcd.print("Your command: ");
        lcd.print(r);
        delay(200);
 
}




/*..............................Master Code..............................*/



#include

char x='w';
void setup()
{
  Wire.begin(1);
  Serial.begin(9600); 
  Wire.onRequest(requestEvent);
}

void loop()
{   
      delay(200);
}
void requestEvent()
{ 
    
    Wire.write(x);
    delay(200);
}
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.