#include #include #define BACKLIGHT_PIN 13 LiquidCrystal_I2C lcd(0x27,16,2); // Set the LCD I2C address //LiquidCrystal_I2C lcd(0x27,16,2, BACKLIGHT_PIN, POSITIVE); // Set the LCD I2C address char * message = "hello maker!"; // Creat a set of new characters const uint8_t charBitmap[][8] = { { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 }, { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 }, { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 }, { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 }, { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 }, { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 }, { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 }, { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 } }; void setup() { lcd.init(); // initialize the lcd lcd.setCursor(3,0); lcd.backlight(); int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0])); // Switch on the backlight pinMode ( BACKLIGHT_PIN, OUTPUT ); digitalWrite ( BACKLIGHT_PIN, HIGH ); for ( int i = 0; i < charBitmapSize; i++ ) { lcd.createChar ( i, (uint8_t *)charBitmap[i] ); } lcd.home (); // go home lcd.print("testing graphics "); lcd.setCursor ( 0, 1 ); // go to the next line lcd.print (" groovy "); delay ( 2000 ); } void loop() { for (int printStart = 15; printStart >= 0; printStart--) //scroll on from right { showLetters(printStart, 0); } for (int letter = 1; letter <= strlen(message); letter++) //scroll off to left { showLetters(0, letter); } } void showLetters(int printStart, int startLetter) { lcd.setCursor(printStart,1); for (int currentLetter = startLetter; currentLetter < strlen(message); currentLetter++) { lcd.print(message[currentLetter]); } lcd.print(" "); delay(250); lcd.home (); // Do a little animation by writing to the same location for ( int i = 0; i < 2; i++ ) { for ( int j = 0; j < 16; j++ ) { lcd.print (char(random(7))); } lcd.setCursor ( 0, 1 ); } delay (200); }