Hardware Reference
In-Depth Information
The r/w parameter is an optional parameter used to indicate if the Arduino is
reading from or writing to the LCD screen. Some applications will write only
to the LCD screen, in which case the R/W pin can be omitted. Otherwise, it
must be connected to the LCD's R/W pin.
The remaining parameters are the data pins. Two options are available: either
selecting four data pins or eight. This means that data sent to or received from
the LCD controller is either in 4-bit mode or 8-bit. Originally, all data was writ-
ten in 8 bits, but 4-bit mode allows programmers to send two 4-bit messages to
be interpreted as an 8-bit message. This allows the designer to save four digital
I/O pins when designing devices.
NOTE There are several misunderstandings about the diff erence between 4-bit
mode and 8-bit mode. One of them is about speed. It is indeed “faster” to send a
single 8-bit message instead of two 4-bit messages, but with more than 90 percent
of alphanumeric LCD screens, speed is not an issue. They have a relatively low refresh
rate, meaning that it is possible to send an entire 2 x 16 message to the LCD screen
before it has time to refresh the screen, even when using 4-bit mode.
When the LiquidCrystal object has been correctly created, it is necessary to
initialize it. This is achieved with begin() .
lcd.begin(cols, rows);
This function requires two parameters: the amount of columns and rows
that the LCD device supports. Typical LCD screens are 2 x 16, but numerous
models exist, and it isn't possible to ask every device what size they are. This
information must be given.
Writing Text
The main function of an alphanumeric LCD screen is, of course, to display text.
Because these screens have a built-in microcontroller, they perform almost
exactly like serial terminals. When you send ASCII text to the controller, it prints
those characters to the LCD screen. Just like a serial console on your computer,
it continues to display those characters until you send more text than can be
displayed, or until you send it an instruction.
To write text directly to the LCD screen, use print() .
result = lcd.print(data);
result = lcd.print(data, BASE);
The data variable is of any data type; typically this would be a chain of
characters, but it can also be numerical data. If it is numerical data, it will be
 
Search WWH ::




Custom Search