Hardware Reference
In-Depth Information
printed as decimal by default, but this can be coni gured using the optional
BASE parameter by selecting one of BIN , DEC , OCT , or HEX . This function returns
a byte , the number of bytes written to the LCD device.
To print a single character, use write() .
result = lcd.write(data);
The data parameter is a character that will be printed to the LCD. This func-
tion returns a byte ; the number of bytes written to the LCD device (in this case,
either 1 if successful, or 0 if there was an error).
To clear the screen, call clear() .
lcd.clear();
This function takes no parameters and does not return any information. It
sends a command to the LCD microcontroller to erase any text on the screen
and to return the cursor to the top-left corner.
Cursor Commands
Cursor functions work similarly to the cursor on a spreadsheet; you may set
the cursor to be at any position, and the text you enter will be printed at that
position. By default, the cursor is set at the top-left side of the screen when ini-
tializing and will be updated to be placed at the end of any text that you write.
When adding text to the display (by using multiple print() calls, for example),
it will be added to the end of the line. So, for example:
lcd.print("Hello, ");
lcd.print("world!");
These two lines will result in printing a single line: “Hello, world!” This is
useful when calling print() several times if displaying numerical values:
lcd.print("Temperature: ");
lcd.print("temp, DEC");
However, you can return the cursor to the top-left of the screen using home() :
lcd.home(); // Returns the cursor to row 0, column 0
You can also place the cursor precisely where you want using the setCursor() :
lcd.setCursor(col, row);
By default, the cursor itself is invisible. To make it visible (as an underscore
at the position where the next character will be printed), use cursor() :
lcd.cursor();
 
Search WWH ::




Custom Search