Challenge

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

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define SLAVE_ADDRESS 0x27 // Adjust the address according to your LCD module
LiquidCrystal_I2C lcd(SLAVE_ADDRESS, 16, 2);

void setup() {void loop() {
lcd.setCursor(0, 1);
lcd.print("Sending message");

Wire.beginTransmission(SLAVE_ADDRESS);
Wire.write("Hello, Slave!"); // The message to be displayed
Wire.endTransmission();

delay(2000); // Delay before sending the next message
lcd.clear();
}

Wire.begin();
lcd.begin(16, 2);
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Master Arduino");
}

void receiveEvent(int numBytes) {
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Received: ");

while (Wire.available()) {
char c = Wire.read();
lcd.print(c);
}
}

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.