by R Jordan Kreindler
The Liquid Crystal Library has two useful functions (line to display text on, string to be scrolled). These
sc ro ll D ispla y Le ft () and sc ro ll D ispla y R igh t () . two functions which scroll lines into the LCD screen
These functions scroll the whole display. That is, they combined with the two functions, sc ro ll Lin e R igh t
scroll both lines on a 1602 LCD and all four lines on a (lin e t o d ispla y t e xt o n , st rin g t o b e
2004 LCD. What we often need is the ability to scroll a sc ro lle d ) and sc ro ll Lin e Le ft (lin e t o d ispla y
single line onto these displays rather than scroll the t e xt o n , st rin g t o b e sc ro lle d ) from my earlier
entire display. Instructable, which presented functions to scroll lines
o the screen, gives us several powerful ways to
This Instructable provides two additional functions, control how text can be presented on, or removed
sc ro ll In Fro mR igh t (lin e t o d ispla y t e xt o n , from, an LCD screen.
st rin g t o b e sc ro lle d ) and sc ro ll In Fro mLe ft
https://youtu.be/bIGZmTozqM8
The items required are an LCD screen either 1602 or - For the independent 1602 LCD display I used the
2004 [if a 2004 is used, it will work without problems following pin assignments in my sketches:
// Liquid Cryst a l (rs, e n a b le , d 4, d 5, d 6, d 7) display was used in this Instructable, but as noted a
1602 shield can be used as well if the di erent pin
Liquid Cryst a l lc d (12, 11, 5, 4, 3, 2); assignments are taken into account.
and included the Liquid Crystal library I used an “experimental platform” to connect the
LiquidCrystal.h. Arduino UNO to a half-size, 400 tie points ,
breadboard. (See an earlier Instructable of mine,
- For the LCD shield, I use the following pin “Expe rime n t a l Pla t fo rm Fo r t h e A rd uin o UN O
assignments in my sketches, and also included the R3, Ho w To Pre pa re I t Fo r Use “). However, an
Liquid Crystal library LiquidCrystal.h. experimental platform is not needed, although for me
it makes connecting the LCD to the UNO much easier
// Liquid Cryst a l (rs, e n a b le , d 4, d 5, d 6, d 7) and quicker.
Liquid Cryst a l lc d (8 , 13, 9, 4, 5, 6, 7); The assignments I used for connecting the LCD to the
UNO can be seen above.
Either route will run the code here, i.e., either a LCD
shield or a standalone LCD. A 1602 standalone LCD
The LCD is plugged into a breadboard and then knob, rather than a shield’s potentiometer which must
hookup wires are connected from the breadboard to be adjusted with a screwdriver.
the appropriate pins on the Arduino (see step 2 if you
have any questions on the connections I used). The standalone LCD requires the use of a separate 10k
ohm potentiometer. As noted above, I used one with a
I preferred a standalone LCD for this project rather knob which has its wiper connected to the third LCD
than a shield as it was more satisfying for me, and pin (counting from the right with the LCD pins facing
allowed me to easily see which pins were available. It you). The potentiometer is used to control the LCD’s
also allows me to use a potentiometer which has a contrast. The connections are the same for the 1602
and the 2004. However, the statement A look at the photographs attached shows the
lc d . b e gin (16, 2) needs to be changed in the sketch hookup I used, including the experimental platform,
to lc d . b e gin (20 , 4) to show that our LCD has and 10k potentiometer.
changed from a 16 character by two line display to a
20 character by four line one.
Just enter the attached sketch into the Arduino IDE. // Liquid Cryst a l (rs, e n a b le , d 4, d 5, d 6, d 7)
Please keep in mind that the Instructable site often
removes all greater than and less than signs and the Liquid Cryst a l lc d (12, 11, 5, 4, 3, 2);
text between them. Thus, be sure and include the
text, #include LiquidCrystal.h and enclose the words // D e c la re lc d a s a Liquid Cryst a l O b je c t
LiquidCrystal.h inside greater than and less than
symbols. in t i = 0 ;
// Ske t c h t o sc ro ll c h a ra c t e rs o n t o a n L CD in t j = 0 ;
sc re e n
in t k = 0 ;
#in c lud e //S e e n o t e in t e xt a b o ut wh a t is
n e e d e d h e re , i. e . , Liquid Cryst a l. h e n c lo se d in t d e la yTime 2 = 350 ; // D e la y b e t we e n
in sid e sh ift s
// gre a t e r t h a n a n d le ss t h a n symb o ls
// Th is sit e o ft e n re mo ve s gre a t e r t h a n a n d
le ss t h a n symb o ls a n d t h e t e xt b e t we e n vo id sc ro ll In Fro mR igh t (in t lin e , c h a r st r1[])
them {
vo id sc ro ll In Fro mLe ft (in t lin e , c h a r st r1[]) { sc ro ll In Fro mR igh t (1, " Lin e 2 Fro m R igh t " );
fo r (k = 0 ; k <= 15; k ++) { sc ro ll In Fro mR igh t (0 , " Lin e 1 Fro m R igh t " );
lc d . prin t (" " ); // Cle a r lin e sc ro ll In Fro mLe ft (1, " Lin e 2 Fro m Le ft ." );
} lc d . c le a r();
lc d . se t Curso r( j, lin e ); }
Step 4: Afterwards
That's all there is to it. These functions and the two If you would like to contact me with any questions or
from my previous Instructable can be added to any for additional information, or to expand my
sketch you have that uses an LCD and displays text. As knowledge in the area presented, I can be reached at
noted, the ability to use longer lines is a de nite transiintbox@gmail.com. (please replace the second 'i'
bene t that is possible through the use of scrolling. with an 'e' to contact me.
I just want to appear on the LCD2004, "Hello World", with this bit of code,
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
lcd.begin();
lcd.backlight();
lcd.print("Hello, world!");
void loop()
}
I had time to think about your problem. Have you run a check on the address of your I2C? Perhaps
it is not 0x27 as you suspect,
Just a thought.
If a differrent library and LCD does not correct the problem, feel free to write again.
I have also used this code, but nothing appears on the screen.
/*
The circuit:
* 5V to Arduino 5V pin
* GND to Arduino GND pin
* CLK to Analog #5
* DAT to Analog #4
*/
// include the library code:
#include "Wire.h"
#include "Adafruit_LiquidCrystal.h"
void setup()
{
// set up the LCD's number of rows and columns:
lcd.begin(20, 4);
void loop()
{
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
I have not used the AdaFruit LCD, so can offer no experience/help in that area.
And what if you have text longer than 16 symbols, that will just stop at the first position.
The 1602 display buffers text beyond the visible 16 characters displayed on the screen, although
not initially presented on the display. That is, there are character positions (buffers) available past
those displayed that can be written to and read from.
Hey just tried editing your code to allow a longer character message and it doesnt work. It will only
display for the message 16 characters long and everything else gets cut off. how might I fix this?
Nice Instructable! It will be great having the ability to move the display one line at a time.
For learning the 16 pin connector works fine but for projects we like the I2C versions and they only
cost about $2 more. The I2C uses only 2 data pins and makes wiring very easy. Well worth it if
putting the display in a project box.
FYI- For inserting code use the 'code' option under formatting. It is a little quirky to use but you
don't lose any characters. You can see it on our Instructables.
Thank you for your kind comments.
I have not needed to include my displays in project boxes, yet, and find the ability to “plug” LCDs
into a breadboard stabilizes them if the appropriate “support feet” are used. See an earlier
Instructable of mine, “Stabilize and level a 1602 or 2004 breadboard-mounted LCD display, A
simple way to”.
I agree with your thoughts on I2C as it does allow many more pins on an Arduino
to be used when necessary. I also appreciate your comments on posting code. Thanks.
The very best.