Pages: [1]   Go Down
Author Topic: Question on LCD display example "HelloWorld" in arduino.  (Read 607 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 213
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys,
I would like to know if I need to change or insert any new command to the example "HelloWorld" in arduino to display in two lines if i am using 16x2 lcd display. Also what is the command or how can I move the message on display so that its in the center.

Thanks. Im just learning so im pretty new to this.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

with lcd.setCursor(0,0);
change the (0)
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 635
Posts: 50263
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
change the (0)
That's not very helpful advice, when there are two 0s in the statement. Which one should be changed?

OP:
Change one 0 to something else, like 1. Observe the results. Then, change it back to 0, and change the other 0 to 1. Observe the results. Now, you know which argument affects the row and which affects the column.

Use that knowledge to put text where you want on the LCD.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26495
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want to centre the text, first call strlen on the string you want to display.
This will give the number of characters in the string, and allow you do some simple arithmetic to enable you to put the cursor in the right place before printing the string.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 499
Posts: 19065
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Look inside LiquidCrystal.cpp. See what the arguments are:

Code:
void LiquidCrystal::setCursor(uint8_t col, uint8_t row)

The first one is clearly the column (ie. left to right) and the second one is the row (top to bottom).
Logged


Pages: [1]   Go Up
Jump to: