LCD I2C SETUP

I2C LCD setup

#include <Wire.h>

#include <LCD.h>

#include <LiquidCrystal_I2C.h>

/*

Connect the LCD: VCC -> 5V, GND -> GND, SDA -> A4 (PortC4, ADC4), SCL -> A5 (PortC5, SDA)

*/

#define I2C_ADDR 0x27

#define BACKLIGHT_PIN 3

#define En_pin 2

#define Rw_pin 1

#define Rs_pin 0

#define D4_pin 4

#define D5_pin 5

#define D6_pin 6

#define D7_pin 7

LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin,BACKLIGHT_PIN,POSITIVE);

LCD *myLCD = &lcd;

int SENSOR_PIN = 0; // center pin of the potentiometer

void setup()

{

lcd.begin(16,2); // initialize the lcd

lcd.home (); // go home

lcd.print(“Hello, ARDUINO “);

delay(100);

}

void loop()

{

int sensorValue = analogRead(SENSOR_PIN);

// set cursor to second row, first column

lcd.setCursor(0, 1);

lcd.print(“PIN VALUE=”);

lcd.setCursor(12, 1);

lcd.print(sensorValue);

lcd.print(“”);

delay (1000);

}

One thought on “LCD I2C SETUP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s