ArduinoLibs: Hello World For Freetronics LCD - GitHub Pages
Maybe your like
| ArduinoLibs |
- Main Page
- Related Pages
- Modules
- Classes
- Files
-
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:
#include <LCD.h> LCD lcd;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:
LCD lcd(A1);The next step is to enable the screen saver and print some text in the setup function:
void setup() { lcd.enableScreenSaver(); lcd.print("hello, world!"); }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:
void loop() { lcd.setCursor(0, 1); lcd.print(millis() / 1000);We then print the name of the button that is currently pressed:
lcd.setCursor(8, 1); int button = lcd.getButton(); if (button == LCD_BUTTON_LEFT) lcd.print("LEFT"); else if (button == LCD_BUTTON_RIGHT) lcd.print("RIGHT"); else if (button == LCD_BUTTON_UP) lcd.print("UP"); else if (button == LCD_BUTTON_DOWN) lcd.print("DOWN"); else if (button == LCD_BUTTON_SELECT) lcd.print("SELECT"); else if (button < 0) // button release lcd.print(" "); }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:
/* This example demonstrates how to use the LCD library, which extends the standard LiquidCrystal library to provide support for the Freetronics back light and Up/Down/Left/Right/Select buttons. More information on the shield here: http://www.freetronics.com/pages/16x2-lcd-shield-quickstart-guide This example is placed into the public domain. */ #include <LCD.h> LCD lcd; // Note: if you are using the USBDroid and have reassigned pin D9 on the LCD shield to some // other pin (e.g. A1), then you will need to initialize the shield with something like: // LCD lcd(A1); // See also: http://www.freetronics.com/pages/combining-the-lcd-keypad-shield-and-the-usbdroid void setup() { lcd.enableScreenSaver(); lcd.print("hello, world!"); } void loop() { lcd.setCursor(0, 1); lcd.print(millis() / 1000); lcd.setCursor(8, 1); int button = lcd.getButton(); if (button == LCD_BUTTON_LEFT) lcd.print("LEFT"); else if (button == LCD_BUTTON_RIGHT) lcd.print("RIGHT"); else if (button == LCD_BUTTON_UP) lcd.print("UP"); else if (button == LCD_BUTTON_DOWN) lcd.print("DOWN"); else if (button == LCD_BUTTON_SELECT) lcd.print("SELECT"); else if (button < 0) // button release lcd.print(" "); } Generated on Sat Apr 7 2018 09:57:39 for ArduinoLibs by
1.8.6 Tag » Arduino Lcd Keypad Shield Hello World
-
Lcd Keypad Shield :: Hello World :: Arduino Uno - Gists · GitHub
-
Arduino LCD 1602 Keypad Shield - Displays
-
Using 1602 LCD Keypad Shield W/ Arduino [w/ Examples]
-
LCD Keypad Shield - Arduino Project Hub
-
Walking Through The 1602 LCD Keypad Shield For Arduino
-
How To Use Arduino LCD Keypad Shield - YouTube
-
Arduino – 4 – Using LCD+Keypad Shield - HandsOn Tech
-
[PDF] LCD Keypad Shield For Arduino - Image
-
PROJECT 1 – “Hello World” ON LCD - Cytron Tutorial
-
LCD_KeyPad_Shield_For_Ardui...
-
Arduino - LCD 1602A KEYPAD LCD SHIELD RELAY CONTROL.
-
210 Lcd Keypad Shield Ideas In 2022 - Pinterest
-
[PDF] LCD KeyPad Shield For Arduino SKU: DFR0009 - Uri=media.digikey