Challenge

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

 Simulation was done on Tinkercad. Tinkecad design link is shown below:

https://www.tinkercad.com/things/86J0BGqIoFD-i2c-lcd-snaget/editel?sharecode=Ptp0U8TPmIiGbtq8YxUPwWqSmf4LZ7vW7Mc2vbcTJ-w

* Screenshot of circuit schematic, PDF schematic & BOM (both downloaded from Tinkercad) are attached

**Screenshots of data send by master-node which is received by the slave-node & displayed on i2c LCD are attached.

***  Arduino Codes of Master-Node and Slave-Node are given below

Master Node Arduino Code

 // Include the required Wire library for I2C
#include

int x = 0;

void setup()
{
Wire.begin(); // Start the I2C Bus as Master
}

void loop()
{
Wire.beginTransmission(9); // transmit to device with address 9
Wire.write(x); // sends x
Wire.endTransmission(); // stop transmitting
x++; // Increment x
if (x > 100)
{
x = 0; // reset x once it gets 100
}
delay(750);
}

Slave Node Arduino Code 

// Include the required Wire library for I2C
#include
#include

int x = 0;
LiquidCrystal_I2C lcd(0x20,16,2); // set the LCD address to 0x20 for a 16 chars and 2 line display

void setup()
{
lcd.init();
lcd.clear();
lcd.backlight(); // Make sure backlight is on

Wire.begin(9); // Start the I2C Bus as Slave on address 9
Wire.onReceive(receiveEvent);

// Print a message on the first line of the LCD.
lcd.setCursor(1,0); //Set cursor to character 2 on line 0
lcd.print("Data Received:");
}

void receiveEvent(int bytes)
{
x = Wire.read(); // read one character from the I2C
}

void loop()
{
lcd.setCursor(2,1); //Move cursor to character 2 on line 1
lcd.print(x);
delay(500);
}

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.