Challenge

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

offline

Interfacing 2*16 LCD with Arduino using I2C protocol.

Program:

// Master
//Name8

#include<Wire.h> //Library


void setup()
{

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

pinMode(A0,INPUT);
}

void loop()
{

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

// slave
//Name1

#include<Wire.h> //Library
#include<LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2); //Define LCD Module Pins(RS, EN, RW, D4, D5, D6, D7, LED(Anode), LED(Cathode))

void setup()
{
Serial.begin(9600);
Wire.begin(1);
Wire.onReceive(volt);
lcd.begin(16,2);
}

void loop()
{

delay(1000);

}

void volt(int y)
{
signed int v=Wire.read();
// Serial.print(v);
//Serial.println(v);
lcd.setCursor(0,0); //Sets cursor at
lcd.print("Output is "); //Prints slave val
lcd.print(v);
delay(1000);
}

Output:

Output using Serial Monitor

Output using LCD

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.