// This example prints text onto a 16x2 character Liquid Crystal // Display (LCD), and scrolls the LCD left and right. #include // include the LiquidCrystal library // Create an lcd object, and specifiy its connections: // lcd RS and E lines connected to pins 6 and 7, // lcd data lines D4-D7 conneected to Arduino pins 0-3. LiquidCrystal myLCD(6,7,0,1,2,3); int pos = 0; // lcd scroll position int dir = 1; // lcd scrolling direction void setup() { pinMode(4,OUTPUT); digitalWrite(4, HIGH); // this sets backlight+ to 5V pinMode(5,OUTPUT); digitalWrite(5, LOW); // this sets backlight- to 0V myLCD.begin(16, 2); // set the correct lcd size (16x2) myLCD.clear(); myLCD.home(); // send cursor to position (0,0) myLCD.print("Hello..."); myLCD.setCursor(8, 1); // move cursor to position (8,1) myLCD.print("Arduino!"); } void loop() { if (dir == 1) { // scroll lcd in direction dir myLCD.scrollDisplayRight(); } else { myLCD.scrollDisplayLeft(); } pos += dir; // update scroll position if (pos < -15 || pos > 15) { dir *= -1; // reverse scroll direction } delay(200); }