ArduinoLibs
|
The LCD class provides an enhanced version of the standard Arduino LiquidCrystal library that supports the additional features of the Freetronics LCD shield; namely the back light and the Up, Down, Left, Right, and Select buttons. This tutorial explains how to use the LCD class to perform basic text output and to use the enhanced shield features.
We start by including the library and initializing it:
Unlike the LiquidCrystal library we don't normally need to specify the pin assignments for this shield. The one exception is when the shield is used with the USBDroid and the D9 pin is reassigned as described on this page. In that case, the initialization sequence would look something like this instead:
The next step is to enable the screen saver and print some text in the setup
function:
The screen saver is a built-in feature of the LCD class that turns off the display and the back light after a specific timeout (the default is 10 seconds). Pressing any of the keys on the shield or calling LCD::display() will wake up the screen again.
In the program's loop
function we print the number of seconds since startup to the second line of the LCD display:
We then print the name of the button that is currently pressed:
The LCD::getButton() function returns the key that has been pressed or released, or LCD_BUTTON_NONE if no key has been pressed or released this time through the loop.
The full source code for the example follows: