#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args)  write(args);
#else
#define printByte(args)  print(args,BYTE);
#endif

byte blue[8] ={ B00100,
                B10110,
                B01101,
                B00110,
                B00110,
                B01101,
                B10110,
                B00100,};
uint8_t bell[8]  = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
uint8_t note[8]  = {0x2,0x3,0x2,0xe,0x1e,0xc,0x0};
uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
uint8_t duck[8]  = {0x0,0xc,0x1d,0xf,0xf,0x6,0x0};
uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0};
uint8_t retarrow[8] = {	0x1,0x1,0x5,0x9,0x1f,0x8,0x4};
  
LiquidCrystal_I2C lcd(0x28,16,2);
LiquidCrystal_I2C lcd2(0x27,16,2);
LiquidCrystal_I2C lcd3(0x29,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup(){
  Serial.begin(115200);
  lcd.init();
  lcd.backlight();
  lcd.print("Ola Mundo!");
  delay(1000);
  lcd2.init();
  lcd2.backlight();
  lcd2.print("Ola Mundo!");
  delay(1000);
  lcd.createChar(0,blue);
  lcd3.init();                      // initialize the lcd 
  lcd3.backlight();
  
  lcd3.createChar(0, bell);
  lcd3.createChar(1, note);
  lcd3.createChar(2, clock);
  lcd3.createChar(3, heart);
  lcd3.createChar(4, duck);
  lcd3.createChar(5, check);
  lcd3.createChar(6, cross);
  lcd3.createChar(7, retarrow);
  lcd3.home();
  
  lcd3.print("Hello world...");
  lcd3.setCursor(0, 1);
  lcd3.print(" i ");
  lcd3.printByte(3);
  lcd3.print(" arduinos!");
  delay(2000);
  //displayKeyCodes();
  
}

// display all keycodes
void displayKeyCodes(void) {
  uint8_t i = 0;
  uint8_t t = 0;
  while (1) {
    lcd3.clear();
    lcd3.print("Codes 0x"); lcd3.print(i, HEX);
    lcd3.print("-0x"); lcd3.print(i+16, HEX);
    lcd3.setCursor(0, 1);
    for (int j=0; j<16; j++) {
      lcd3.printByte(i+j);
      t = (i+j);
      delay(100);
    }
    if(t == 255){
      break;
    }
    i+=16;
    
    delay(2000);
    
  }
}

void loop(){
  lcd3.clear();
  lcd3.setCursor(0,0);
  lcd3.write(0);
  lcd3.write(1);
  lcd3.write(2);
  lcd3.write(3);
  lcd3.write(4);
  lcd3.write(5);
  lcd3.write(6);
  lcd3.write(7);
  //lcd3.write(8);
  if(Serial){
    lcd.setCursor(15,0);
    lcd.write(0);    
  }
  while(Serial){}
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
lcd1:GND
lcd1:VCC
lcd1:SDA
lcd1:SCL
lcd2:GND
lcd2:VCC
lcd2:SDA
lcd2:SCL
lcd3:GND
lcd3:VCC
lcd3:SDA
lcd3:SCL