Challenge

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

Overview of the Project:

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

Goals:

  • Communication between Arduino and 16*2 LCD using I2C protocol.
  • Displaying the message sent by Master and received by slave i.e. LCD display.

Key Highlights of the Project:

  • Using the inter-integrated circuit communication protocol, transferring the data i.e. the message we want to display is sent to the LCD.
  • Two Arduino’s connected to the LCD display and the communication is executed using I2C protocol between Arduino and the LDC display.

Deliverables of this project:

  • Communication between the Arduino’s and LCD using I2C.
  • The message passed from master to slave and displayed on the 16*2 LCD.

Expected Outcomes:

  • Students will get the Knowledge of I2C communication Protocol and the Arduino.
  • The Hardware connection of all components used in this project.
  • Displaying the message sent by master (Arduino) and received by the slave (16*2 LCD display).

SOLUTION_

Hardware Required:

2 x Arduino boards (Uno, Nano, etc.)

1 x 16x2 LCD Display

1 x I2C Module (for communication)

Resister 2

Jumper wires

Electrical Connections:

Master Arduino:

Connect SDA pin to A4 on Arduino.

Connect SCL pin to A5 on Arduino.

Connect VCC and GND to their respective pins on Arduino.

Slave Arduino:

Connect SDA pin to A4 on Arduino.

Connect SCL pin to A5 on Arduino.

Connect VCC and GND to their respective pins on Arduino.

LCD:

Connect SDA and SCL pins to the corresponding pins on the I2C module.

Connect VCC and GND to their respective pins on the I2C module.

MASTER CODE

#include

#include

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

void setup() {

Serial.begin(9600); // Initialize the serial communication for debugging purposes

Wire.begin(); // Initialize I2C communication

lcd.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows

}

void loop() {

Wire.requestFrom(10,20); // Request 20 bytes from the device with I2C address 10

while(Wire.available())

{

char c= Wire.read(); // Read the received character from the I2C bus

Serial.print(c); // Print the received character to the Serial Monitor for debugging

lcd.print(c); // Print the received character on the LCD

// The above two lines print each character received from the I2C bus to both Serial

}

lcd.setCursor(0, 0); // Set the LCD cursor to the beginning of the first line

Serial.print(" "); // Print a space to clear the line on the Serial Monitor

delay(500); // Introduce a delay to slow down the loop (adjust as needed)

}

SLAVE CODE

#include

void setup()

{

Wire.begin(10); // Initialize I2C communication with a slave address of 10

Wire.onRequest(requestEvent); // Set up the onRequest event handler

}

void loop()

{

delay (100); // Introduce a delay to avoid excessive loop iterations

}

void requestEvent() {

Wire.write("GOOD MORNING WORLD "); // Send the string "GOOD MORNING WORLD" when requested

}

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.