Challenge

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

Interfacing a 16*2 LCD with Arduino using I2C protocol:

Master:

#include
void setup()
{
Serial.begin(9600);
Serial.println("master"); //serial print
Wire.begin();
}

void loop()
{
int mydata= 55; //data passed from master to slave
Wire.beginTransmission(1); //tr data
Wire.write(mydata); //55
Wire.endTransmission();
}

Slave:

#include //preprocessor
#include //preprocessor
LiquidCrystal lcd(12,11,5,4,3,2); //lcd out
void setup()
{
Serial.begin(9600); //clk cycles
lcd.begin(16,2); //lcd start
Wire.begin(1);
Wire.onReceive(myfunction); //caller fun
}
void myfunction(int p)
{
int a=Wire.read(); //read fun
lcd.setCursor(1,1);
lcd.print(" skill-lync "); //print on lcd

lcd.print(a); //called fun
delay(500); //delay
}

void loop()
{

}

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.