Challenge

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

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

1a)

Slave.

#include<Wire.h>

#include<LiquidCrystal.h>

LiquidCrystal lcd(13,12,5,4,3,2);

void setup()

{

Serial.begin(9600);

lcd.begin(16,2);

Wire.begin(1);

Wire.onReceive(myfunction);

}

void myfunction(int p)

{

int a=Wire.read();

lcd.setCursor(4,0);

lcd.print(a);

delay(500);

}

void loop()

{

}

1b).

Master.

#include<Wire.h>

void setup()

{

Serial.begin(9600);

Serial.println("master");

Wire.begin();

}

void loop()

{

int mydata=5;

Wire.beginTransmission(1);

Wire.write(mydata);

Wire.endTransmission();

}

https://www.tinkercad.com/things/2CTfK0dtJsb-fundemental-project-1/editel?sharecode=iNem3NvW8EYIPnQSTrbugzjItuRL8E7JDB2bT1tixuI

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.