CustomChars.pde (1612B)
1 //YWROBOT 2 //Compatible with the Arduino IDE 1.0 3 //Library version:1.1 4 #include <Wire.h> 5 #include <LiquidCrystal_I2C.h> 6 7 #if defined(ARDUINO) && ARDUINO >= 100 8 #define printByte(args) write(args); 9 #else 10 #define printByte(args) print(args,BYTE); 11 #endif 12 13 uint8_t bell[8] = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4}; 14 uint8_t note[8] = {0x2,0x3,0x2,0xe,0x1e,0xc,0x0}; 15 uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0}; 16 uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0}; 17 uint8_t duck[8] = {0x0,0xc,0x1d,0xf,0xf,0x6,0x0}; 18 uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0}; 19 uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0}; 20 uint8_t retarrow[8] = { 0x1,0x1,0x5,0x9,0x1f,0x8,0x4}; 21 22 LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display 23 24 void setup() 25 { 26 lcd.init(); // initialize the lcd 27 lcd.backlight(); 28 29 lcd.createChar(0, bell); 30 lcd.createChar(1, note); 31 lcd.createChar(2, clock); 32 lcd.createChar(3, heart); 33 lcd.createChar(4, duck); 34 lcd.createChar(5, check); 35 lcd.createChar(6, cross); 36 lcd.createChar(7, retarrow); 37 lcd.home(); 38 39 lcd.print("Hello world..."); 40 lcd.setCursor(0, 1); 41 lcd.print(" i "); 42 lcd.printByte(3); 43 lcd.print(" arduinos!"); 44 delay(5000); 45 displayKeyCodes(); 46 47 } 48 49 // display all keycodes 50 void displayKeyCodes(void) { 51 uint8_t i = 0; 52 while (1) { 53 lcd.clear(); 54 lcd.print("Codes 0x"); lcd.print(i, HEX); 55 lcd.print("-0x"); lcd.print(i+16, HEX); 56 lcd.setCursor(0, 1); 57 for (int j=0; j<16; j++) { 58 lcd.printByte(i+j); 59 } 60 i+=16; 61 62 delay(4000); 63 } 64 } 65 66 void loop() 67 { 68 69 } 70