#include #include #include #include // F Malpartida's NewLiquidCrystal library //Download: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads // Move original LiquidCrystal library elsewhere, copy this in it's place /*-----( Declare Constants )-----*/ #define I2C_ADDR 0x20 // 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 /*-----( Declare objects )-----*/ LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin); // Creat a set of new characters byte smiley[8] = { 0b00000, 0b00000, 0b01010, 0b00000, 0b00000, 0b10001, 0b01110, 0b00000 }; byte armsUp[8] = { 0b00100, 0b01010, 0b00100, 0b10101, 0b01110, 0b00100, 0b00100, 0b01010 }; byte frownie[8] = { 0b00000, 0b00000, 0b01010, 0b00000, 0b00000, 0b00000, 0b01110, 0b10001 }; void setup() { Serial.begin ( 57600 ); // Switch on the backlight and LCD contrast levels // pinMode(CONTRAST_PIN, OUTPUT); // analogWrite ( CONTRAST_PIN, CONTRAST ); lcd.setBacklightPin ( BACKLIGHT_PIN, POSITIVE ); lcd.setBacklight ( LED_ON ); lcd.backlight(); lcd.begin(16,2); // initialize the lcd lcd.createChar (0, smiley); // load character to the LCD lcd.createChar (1, armsUp); // load character to the LCD lcd.createChar (2, frownie); // load character to the LCD lcd.home (); // go home lcd.print("Hello, ARDUINO "); lcd.setCursor ( 0, 1 ); // go to the next line lcd.print (" FORUM - fm "); } void loop() { // Do a little animation by writing to the same location lcd.setCursor ( 14, 1 ); lcd.print (char(2)); delay (2000); lcd.setCursor ( 14, 1 ); lcd.print ( char(1)); delay (2000); lcd.setCursor ( 14, 1 ); lcd.print ( char(0)); delay (2000); }