CustomChars.pde 1.6 KB

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