Challenge

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

OFFLINE EMBEDDED BATCH1

Master Program


#include<Wire.h>

void setup()
{

Serial.begin(9600);
Wire.begin();

}

void loop()
{

int value=analogRead(A0);
signed int voltage=((value*5)/1024);
Wire.beginTransmission(1);
Wire.write(voltage);
Wire.endTransmission();
delay(1000);
}

Slave Program


#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
void setup()
{
lcd.begin(16,2);
Serial.begin(9600);
Wire.begin(1);
Wire.onReceive(display);
}
void loop()
{
delay(30);
}

void display(int value)
{

signed int x=Wire.read();
lcd.setCursor(0,0);
lcd.print("voltage is ");
lcd.print(x);
delay(1000);
Serial.print("voltage value is\n");
Serial.println(x);

}

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.