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

CODE FOR MASTER NODE :-
#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // initialised all pin which used with lcd
void setup() {
Wire.begin();
lcd.begin(16, 2);
Wire.requestFrom(8, 4); // request 4 bytes from peripheral device #8
lcd.print("chauhan ");
while (Wire.available()) { // peripheral may send less than requested
char c = Wire.read(); // receive a byte as character
lcd.print(c); // print the character
}
}
void loop() {
delay(300);
}
SLAVE NODE CODE :-
#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Wire.begin(8); // join i2c bus with address #8
Wire.onRequest(requestEvent); // register event
}
void loop() {
delay(100);
}
void requestEvent() {
Wire.write("ravi");
}