Skip to content

Instantly share code, notes, and snippets.

@hezhao
Created March 24, 2014 22:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hezhao/9750621 to your computer and use it in GitHub Desktop.
Save hezhao/9750621 to your computer and use it in GitHub Desktop.
YwRobot LCM1602 IIC V1 20x4 LCD Display with PCF8574T
// See http://forum.arduino.cc/index.php?topic=158312.0
// NewLiquidCrystal library
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x27 // Define I2C Address for the PCF8574T
//---(Following are the PCF8574 pin assignments to LCD connections )----
// This are different than earlier/different I2C LCD displays
#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
#define LED_OFF 1
#define LED_ON 0
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);
void setup()
{
lcd.begin (20, 4); // 20x4 characters
lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd.setBacklight(LED_ON);
}
void loop()
{
// Reset the display
lcd.clear();
delay(1000);
lcd.home();
// Print our characters on the LCD
lcd.backlight(); //Backlight ON if under program control
lcd.setCursor(3, 0); //Start at character 3 on line 0
lcd.print("Hello, world!");
delay(1000);
lcd.setCursor(2, 1);
lcd.print("From YourDuino");
delay(1000);
lcd.setCursor(0, 2);
lcd.print("20 by 4 Line Display");
lcd.setCursor(0, 3);
delay(1000);
lcd.print("http://YourDuino.com");
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment