Challenge

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

Code for Master:

#include

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

int masterValue = 100;

void setup() {

lcd.begin(16, 2);

Serial.begin(9600); // Initialize serial communication

}

void loop() {

lcd.setCursor(0, 0);

lcd.print(">> Master <<");

lcd.setCursor(0, 1);

lcd.print("MasterVal: " + String(masterValue));

// Send the value to the slave

Serial.println(masterValue);

delay(1000);

}

Code for Slave Arduino

#include

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

int slaveValue = 0;

void setup() {

lcd.begin(16, 2);

Serial.begin(9600); // Initialize serial communication

}

void loop() {

lcd.setCursor(0, 0);

lcd.print(">> Slave <<");

lcd.setCursor(0, 1);

lcd.print("SlaveVal: " + String(slaveValue));

delay(1000);

}

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.