Advertisement
IMiljancic

Untitled

Jul 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LiquidCrystal_I2C.h>
  3.  
  4.  
  5.  
  6. #define BACKLIGHT_PIN 13
  7.  
  8. LiquidCrystal_I2C lcd(0x20); // Set the LCD I2C address
  9.  
  10. //LiquidCrystal_I2C lcd(0x38, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address
  11.  
  12.  
  13. // Creat a set of new characters
  14. const uint8_t charBitmap[][8] = {
  15. { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
  16. { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
  17. { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
  18. { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
  19. { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
  20. { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
  21. { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
  22. { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
  23.  
  24. };
  25.  
  26. void setup()
  27. {
  28. int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
  29.  
  30. // Switch on the backlight
  31. pinMode ( BACKLIGHT_PIN, OUTPUT );
  32. digitalWrite ( BACKLIGHT_PIN, HIGH );
  33.  
  34. lcd.begin(16,2); // initialize the lcd
  35.  
  36. for ( int i = 0; i < charBitmapSize; i++ )
  37. {
  38. lcd.createChar ( i, (uint8_t *)charBitmap[i] );
  39. }
  40.  
  41. lcd.home (); // go home
  42. lcd.print("Hello, ARDUINO ");
  43. lcd.setCursor ( 0, 1 ); // go to the next line
  44. lcd.print (" FORUM - fm ");
  45. delay ( 1000 );
  46. }
  47.  
  48. void loop()
  49. {
  50. lcd.home ();
  51. // Do a little animation by writing to the same location
  52. for ( int i = 0; i < 2; i++ )
  53. {
  54. for ( int j = 0; j < 16; j++ )
  55. {
  56. lcd.print (char(random(7)));
  57. }
  58. lcd.setCursor ( 0, 1 );
  59. }
  60. delay (200);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement