[136] | 1 | /*
|
---|
| 2 | LiquidCrystal Library - Autoscroll
|
---|
| 3 |
|
---|
| 4 | Demonstrates the use a 16x2 LCD display. The LiquidCrystal
|
---|
| 5 | library works with all LCD displays that are compatible with the
|
---|
| 6 | Hitachi HD44780 driver. There are many of them out there, and you
|
---|
| 7 | can usually tell them by the 16-pin interface.
|
---|
| 8 |
|
---|
| 9 | This sketch demonstrates the use of the autoscroll()
|
---|
| 10 | and noAutoscroll() functions to make new text scroll or not.
|
---|
| 11 |
|
---|
| 12 | The circuit:
|
---|
| 13 | * LCD RS pin to digital pin 12
|
---|
| 14 | * LCD Enable pin to digital pin 11
|
---|
| 15 | * LCD D4 pin to digital pin 5
|
---|
| 16 | * LCD D5 pin to digital pin 4
|
---|
| 17 | * LCD D6 pin to digital pin 3
|
---|
| 18 | * LCD D7 pin to digital pin 2
|
---|
| 19 | * LCD R/W pin to ground
|
---|
| 20 | * 10K resistor:
|
---|
| 21 | * ends to +5V and ground
|
---|
| 22 | * wiper to LCD VO pin (pin 3)
|
---|
| 23 |
|
---|
| 24 | Library originally added 18 Apr 2008
|
---|
| 25 | by David A. Mellis
|
---|
| 26 | library modified 5 Jul 2009
|
---|
| 27 | by Limor Fried (http://www.ladyada.net)
|
---|
| 28 | example added 9 Jul 2009
|
---|
| 29 | by Tom Igoe
|
---|
| 30 | modified 22 Nov 2010
|
---|
| 31 | by Tom Igoe
|
---|
| 32 |
|
---|
| 33 | This example code is in the public domain.
|
---|
| 34 |
|
---|
| 35 | http://arduino.cc/en/Tutorial/LiquidCrystalAutoscroll
|
---|
| 36 |
|
---|
| 37 | */
|
---|
| 38 |
|
---|
| 39 | // include the library code:
|
---|
| 40 | #include <LiquidCrystal.h>
|
---|
| 41 |
|
---|
| 42 | // initialize the library with the numbers of the interface pins
|
---|
| 43 | LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
|
---|
| 44 |
|
---|
| 45 | void setup() {
|
---|
| 46 | // set up the LCD's number of columns and rows:
|
---|
| 47 | lcd.begin(16, 2);
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | void loop() {
|
---|
| 51 | // set the cursor to (0,0):
|
---|
| 52 | lcd.setCursor(0, 0);
|
---|
| 53 | // print from 0 to 9:
|
---|
| 54 | for (int thisChar = 0; thisChar < 10; thisChar++) {
|
---|
| 55 | lcd.print(thisChar);
|
---|
| 56 | delay(500);
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | // set the cursor to (16,1):
|
---|
| 60 | lcd.setCursor(16, 1);
|
---|
| 61 | // set the display to automatically scroll:
|
---|
| 62 | lcd.autoscroll();
|
---|
| 63 | // print from 0 to 9:
|
---|
| 64 | for (int thisChar = 0; thisChar < 10; thisChar++) {
|
---|
| 65 | lcd.print(thisChar);
|
---|
| 66 | delay(500);
|
---|
| 67 | }
|
---|
| 68 | // turn off automatic scrolling
|
---|
| 69 | lcd.noAutoscroll();
|
---|
| 70 |
|
---|
| 71 | // clear screen for the next loop:
|
---|
| 72 | lcd.clear();
|
---|
| 73 | }
|
---|
| 74 |
|
---|