Challenge

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

EMBEDDED OFFLINE BATCH:

TITLE:Interfacing a 16*2 LCD with Arduino using I2C protocol

CODING

//MASTER

#include<Wire.h>\\Header File for Wire Transmission on Arduino
#include<LiquidCrystal.h>\\Header File for LCD Cofiguration
void setup()
{
LiquidCrystal lcd(12,11,5,4,3,2);\\Configuration of LCD PIN
lcd.begin(16,2);\\LCD Intialization

Serial.begin(9600);\\Baud Rate
Wire.begin(8);
Wire.onReceive(display);
}

void loop()
{

delay(30);\\Timer Delay


}
void display(int x)\\Display function
{
LiquidCrystal lcd(12,11,5,4,3,2);
int y=Wire.read();
Serial.println(y);
lcd.setCursor(1,0);
lcd.print("the volt is");
lcd.print(y);
delay(1000);
}

//SLAVE:

#include<Wire.h>
void setup()
{
Serial.begin(9600);
Wire.begin();
pinMode(A0,INPUT);


}

void loop()
{

float x=analogRead(A0);
float value=((x*5)/1024);
signed int temp=((value-0.5)*100);
Wire.beginTransmission(8);
Wire.write(temp);
Wire.endTransmission();
//Serial.println(temp);
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.