source: rtos_arduino/trunk/arduino_lib/libraries/LiquidCrystal/examples/TextDirection/TextDirection.ino@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.7 KB
Line 
1/*
2LiquidCrystal Library - TextDirection
3
4Demonstrates the use a 16x2 LCD display. The LiquidCrystal
5library works with all LCD displays that are compatible with the
6Hitachi HD44780 driver. There are many of them out there, and you
7can usually tell them by the 16-pin interface.
8
9This sketch demonstrates how to use leftToRight() and rightToLeft()
10to move the cursor.
11
12The 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
24Library originally added 18 Apr 2008
25by David A. Mellis
26library modified 5 Jul 2009
27by Limor Fried (http://www.ladyada.net)
28example added 9 Jul 2009
29by Tom Igoe
30modified 22 Nov 2010
31by Tom Igoe
32
33This example code is in the public domain.
34
35http://arduino.cc/en/Tutorial/LiquidCrystalTextDirection
36
37*/
38
39// include the library code:
40#include <LiquidCrystal.h>
41
42// initialize the library with the numbers of the interface pins
43LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
44
45int thisChar = 'a';
46
47void setup() {
48 // set up the LCD's number of columns and rows:
49 lcd.begin(16, 2);
50 // turn on the cursor:
51 lcd.cursor();
52}
53
54void loop() {
55 // reverse directions at 'm':
56 if (thisChar == 'm') {
57 // go right for the next letter
58 lcd.rightToLeft();
59 }
60 // reverse again at 's':
61 if (thisChar == 's') {
62 // go left for the next letter
63 lcd.leftToRight();
64 }
65 // reset at 'z':
66 if (thisChar > 'z') {
67 // go to (0,0):
68 lcd.home();
69 // start again at 0
70 thisChar = 'a';
71 }
72 // print the character
73 lcd.write(thisChar);
74 // wait a second:
75 delay(1000);
76 // increment the letter:
77 thisChar++;
78}
79
80
81
82
83
84
85
86
Note: See TracBrowser for help on using the repository browser.