~ubuntu-branches/debian/experimental/arduino/experimental

« back to all changes in this revision

Viewing changes to libraries/LiquidCrystal/examples/Scroll/Scroll.pde

  • Committer: Package Import Robot
  • Author(s): Scott Howard
  • Date: 2012-03-11 18:19:42 UTC
  • mfrom: (1.1.5) (5.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20120311181942-be2clnbz1gcehixb
Tags: 1:1.0.1~rc1+dfsg-1
New upstream release, experimental.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight()
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 prints "Hello World!" to the LCD and uses the
10
 
 scrollDisplayLeft() and scrollDisplayRight() methods to scroll
11
 
 the text.
12
 
 
13
 
  The circuit:
14
 
 * LCD RS pin to digital pin 12
15
 
 * LCD Enable pin to digital pin 11
16
 
 * LCD D4 pin to digital pin 5
17
 
 * LCD D5 pin to digital pin 4
18
 
 * LCD D6 pin to digital pin 3
19
 
 * LCD D7 pin to digital pin 2
20
 
 * LCD R/W pin to ground
21
 
 * 10K resistor:
22
 
 * ends to +5V and ground
23
 
 * wiper to LCD VO pin (pin 3)
24
 
 
25
 
 Library originally added 18 Apr 2008
26
 
 by David A. Mellis
27
 
 library modified 5 Jul 2009
28
 
 by Limor Fried (http://www.ladyada.net)
29
 
 example added 9 Jul 2009
30
 
 by Tom Igoe 
31
 
 modified 22 Nov 2010
32
 
 by Tom Igoe
33
 
 
34
 
 This example code is in the public domain.
35
 
 
36
 
 http://www.arduino.cc/en/Tutorial/LiquidCrystal
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
 
  // Print a message to the LCD.
49
 
  lcd.print("hello, world!");
50
 
  delay(1000);
51
 
}
52
 
 
53
 
void loop() {
54
 
  // scroll 13 positions (string length) to the left 
55
 
  // to move it offscreen left:
56
 
  for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
57
 
    // scroll one position left:
58
 
    lcd.scrollDisplayLeft(); 
59
 
    // wait a bit:
60
 
    delay(150);
61
 
  }
62
 
 
63
 
  // scroll 29 positions (string length + display length) to the right
64
 
  // to move it offscreen right:
65
 
  for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
66
 
    // scroll one position right:
67
 
    lcd.scrollDisplayRight(); 
68
 
    // wait a bit:
69
 
    delay(150);
70
 
  }
71
 
  
72
 
    // scroll 16 positions (display length + string length) to the left
73
 
    // to move it back to center:
74
 
  for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
75
 
    // scroll one position left:
76
 
    lcd.scrollDisplayLeft(); 
77
 
    // wait a bit:
78
 
    delay(150);
79
 
  }
80
 
  
81
 
  // delay at the end of the full loop:
82
 
  delay(1000);
83
 
 
84
 
}
85