Introduction: Arduino LCD Scrolling and Flashing Emulation
Most of Arduino LCD can use autoscroll() member function to scroll text. This function however will scroll all rows of text in LCD. In this Instructables we will show how to scroll and flash text in each row by using simple software tricks.
Step 1: Equipment
We'll need the following devices for this simple project:
- Ameba Arduino board - You can search eBay using "Ameba Arduino" about it. I used this board simply because it's handy. You can use any Arduino or compatible board for this project.
- Arduino I2C 2×16 LCD - You can get this serial LCD module by searching eBay using "Arduino I2C 2×16 LC". You can also use any HD44780 compatible parallel LCD for this project. By adding an extra LCM1602 module, the parallel LCD can be transformed into serial LCD thus simplify the wiring. The LCM1602 module just shift the clock-in data into I/O port.
Step 2: Wiring
There are four wires in the serial LCD module and the connection to Arduino board is simple:
GND - Arduino GND
VCC - Arduino 5V
SDA - Arduino A4
SCL - Arduino A5
Step 3: Code Reference
The Arduino sketch is attached for your reference. The needed LiquidCrystal_I2C.h header file is built-in for Ameba Arduino board. if you are using Arduino board and need this I2C library, please refer to another Instructables:
The required settings of each model of LCD might be different, the constructor we use in this example is:
LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t En, uint8_t Rw, uint8_t Rs, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, uint8_t backlighPin, t_backlighPol pol);
And the setting parameters are as follows:
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
The first parameter 0x27 is the address of I2C. Each of the following 8 parameters represents the meaning of each bit in a byte, i.e., En is bit 2, Rw is bit 1, Rs is bit 0, d4 is bit 4, and so forth.
Call backlight() to light the screen, call setCursor(0, 0) to set the position of the cursor. LCD inherits the Print class, so we can use lcd.print() to output string on the screen.
The trick to emulate the scrolling: Loop through the length of the string and print out the string starting from the loop index in each iteration in the first row. We also print out a string "Flashing line..." in seconf row only in even iteration to emulate the flashing effect.