Table of Contents
Scroll data on LCD 16×2 using Arduino is a cool and attractive feature available for LCD screens. People generally notice and pay attention to Scrolling.
To scroll data on the LCD screen we must keep in mind the concept we used in setting up cursor position, for scrolling data from left to right we will change the column index from 0 (or even negative value) to 15 with row 0 or 1. We will use for loop to increase the index let check the code below:
NOTE: Most important thing in scrolling is deleting the previous data from the screen by using the clear() function. Syntax: object.clear(). Recommended: Try code with and without clear() function to find out the differences.
CIRCUIT DIAGRAM
CONNECTION TABLE FOR LCD AND ARDUINO
S.N. | Arduino Pin | LCD pin | |
---|---|---|---|
1. | 1. VSS | Ground (0V) | |
2. | 2. VCC | + 5V | |
3. | 3. VEE | 10K POT | |
4. | 2 | 4. RS | |
5. | 5. RW | Ground | |
6. | 3 | 6. E | |
7. | 7. D0 | - | |
8. | 8. D1 | - | |
9. | 9. D2 | - | |
10. | 10. D3 | - | |
11. | 4 | 11. D4 | |
12. | 5 | 12. D5 | |
13. | 6 | 13. D6 | |
14. | 7 | 14. D7 | |
15. | 15. Anode + | + 5V | |
16. | 16. Cathode - | 0V (Ground) |
ARDUINO CODE FOR DATA SCROLLING ON LCD USING ARDUINO
// delay variable del with a value of 200 for 200 ms #define del 200 #include<LiquidCrystal.h> LiquidCrystal lcd(2, 3, 4, 5, 6, 7); int i = 0 , j = 0; void setup( ) { lcd.begin(16, 2); } void loop( ) { //(1) Scrolling from Left to Right // Use 0 instead of -5 and check out the difference for (j = -5 ; j <= 16 ; j++) { lcd.setCursor(j, i); lcd.print("HELLO"); delay(del); lcd.clear( ); }// end of for loop (1) // (2)Scrolling from Right to Left for (j = 16 ; j >= -5 ; j--) { lcd.setCursor(j, i); lcd.print("HELLO"); delay(del); lcd.clear( ); }// end of for loop (2) // (3) scrolling in first row from Left-Right-Left then in second row from Left-Right-Left for (i = 0 ; i <= 1 ; i++) { for (j = -5 ; j <= 16 ; j++) { lcd.setCursor(j, i); lcd.print("HELLO "); delay(del); lcd.clear( ); } for (j = 16 ; j >= -5 ; j--) { lcd.setCursor(j, i); lcd.print("HELLO "); delay(del); lcd.clear( ); } }// end of for loop (3) }// end of loop
OUTPUT
READ NEXT
PRINT ASCII CHARACTERS ON LCD 16×2 USING ARDUINO