Skip to content

Commit f30af5e

Browse files
committed
Adding Tom's examples for the new LiquidCrystal library.
1 parent b630120 commit f30af5e

File tree

9 files changed

+559
-0
lines changed

9 files changed

+559
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
LiquidCrystal Library - Blink
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 makes the
10+
cursor block blink.
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+
* 10K resistor:
20+
* ends to +5V and ground
21+
* wiper to LCD VO pin (pin 3)
22+
23+
Library originally added 18 Apr 2008
24+
by David A. Mellis
25+
library modified 5 Jul 2009
26+
by Limor Fried (http://www.ladyada.net)
27+
example added 9 Jul 2009
28+
by Tom Igoe
29+
30+
http://www.arduino.cc/en/Tutorial/LiquidCrystal
31+
32+
*/
33+
34+
// include the library code:
35+
#include <LiquidCrystal.h>
36+
37+
// initialize the library with the numbers of the interface pins
38+
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
39+
40+
void setup() {
41+
// set up the LCD's number of rows and columns:
42+
lcd.begin(2, 16);
43+
// Print a message to the LCD.
44+
lcd.print("hello, world!");
45+
}
46+
47+
void loop() {
48+
// Turn off the display:
49+
lcd.noBlink();
50+
delay(500);
51+
// Turn on the display:
52+
lcd.blink();
53+
delay(500);
54+
}
55+
56+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
LiquidCrystal Library - Cursor
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
10+
uses the cursor() and noCursor() methods to turn
11+
on and off the cursor.
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+
* 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+
31+
http://www.arduino.cc/en/Tutorial/LiquidCrystal
32+
*/
33+
34+
// include the library code:
35+
#include <LiquidCrystal.h>
36+
37+
// initialize the library with the numbers of the interface pins
38+
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
39+
40+
void setup() {
41+
// set up the LCD's number of rows and columns:
42+
lcd.begin(2, 16);
43+
// Print a message to the LCD.
44+
lcd.print("hello, world!");
45+
}
46+
47+
void loop() {
48+
// Turn off the display:
49+
lcd.noCursor();
50+
delay(500);
51+
// Turn on the display:
52+
lcd.cursor();
53+
delay(500);
54+
}
55+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
LiquidCrystal Library - display() and noDisplay()
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+
display() and noDisplay() functions to turn on and off
11+
the display.
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+
* 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+
31+
http://www.arduino.cc/en/Tutorial/LiquidCrystal
32+
*/
33+
34+
// include the library code:
35+
#include <LiquidCrystal.h>
36+
37+
// initialize the library with the numbers of the interface pins
38+
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
39+
40+
void setup() {
41+
// set up the LCD's number of rows and columns:
42+
lcd.begin(2, 16);
43+
// Print a message to the LCD.
44+
lcd.print("hello, world!");
45+
}
46+
47+
void loop() {
48+
// Turn off the display:
49+
lcd.noDisplay();
50+
delay(500);
51+
// Turn on the display:
52+
lcd.display();
53+
delay(500);
54+
}
55+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
LiquidCrystal Library - Hello World
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
10+
and shows the time.
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+
* 10K resistor:
20+
* ends to +5V and ground
21+
* wiper to LCD VO pin (pin 3)
22+
23+
Library originally added 18 Apr 2008
24+
by David A. Mellis
25+
library modified 5 Jul 2009
26+
by Limor Fried (http://www.ladyada.net)
27+
example added 9 Jul 2009
28+
by Tom Igoe
29+
30+
http://www.arduino.cc/en/Tutorial/LiquidCrystal
31+
*/
32+
33+
// include the library code:
34+
#include <LiquidCrystal.h>
35+
36+
// initialize the library with the numbers of the interface pins
37+
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
38+
39+
void setup() {
40+
// set up the LCD's number of rows and columns:
41+
lcd.begin(2, 16);
42+
// Print a message to the LCD.
43+
lcd.print("hello, world!");
44+
}
45+
46+
void loop() {
47+
// set the cursor to column 0, line 1
48+
// (note: line 1 is the second row, since counting begins with 0):
49+
lcd.setCursor(0, 1);
50+
// print the number of seconds since reset:
51+
lcd.print(millis()/1000);
52+
}
53+
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
LiquidCrystal Library - Increment/Decrement
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 shiftIncrement()
10+
and shifDecrement() functions.
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+
* 10K resistor:
20+
* ends to +5V and ground
21+
* wiper to LCD VO pin (pin 3)
22+
23+
Library originally added 18 Apr 2008
24+
by David A. Mellis
25+
library modified 5 Jul 2009
26+
by Limor Fried (http://www.ladyada.net)
27+
example added 9 Jul 2009
28+
by Tom Igoe
29+
30+
http://www.arduino.cc/en/Tutorial/LiquidCrystal
31+
*/
32+
33+
// include the library code:
34+
#include <LiquidCrystal.h>
35+
36+
// initialize the library with the numbers of the interface pins
37+
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
38+
39+
void setup() {
40+
// set up the LCD's number of rows and columns:
41+
lcd.begin(2, 16);
42+
}
43+
44+
void loop() {
45+
// set the cursor to (0,0):
46+
lcd.setCursor(0, 0);
47+
// set the display to left justify:
48+
lcd.shiftDecrement();
49+
// print from 0 to 9:
50+
for (int thisChar = 0; thisChar < 10; thisChar++) {
51+
lcd.print(thisChar);
52+
delay(500);
53+
}
54+
// set the cursor to (16,0):
55+
lcd.setCursor(16,1);
56+
// set the display to left justify:
57+
lcd.shiftIncrement();
58+
// print from 0 to 9:
59+
for (int thisChar = 0; thisChar < 10; thisChar++) {
60+
lcd.print(thisChar);
61+
delay(500);
62+
}
63+
64+
// clear screen for the next loop:
65+
lcd.clear();
66+
}
67+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
* 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+
31+
http://www.arduino.cc/en/Tutorial/LiquidCrystal
32+
*/
33+
34+
// include the library code:
35+
#include <LiquidCrystal.h>
36+
37+
// initialize the library with the numbers of the interface pins
38+
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
39+
40+
void setup() {
41+
// set up the LCD's number of rows and columns:
42+
lcd.begin(2, 16);
43+
lcd.setCursor(0,7);
44+
// Print a message to the LCD.
45+
lcd.print("hello, world!");
46+
}
47+
48+
void loop() {
49+
// scroll 27 positions (display length + string length) to the left:
50+
for (int positionCounter = 0; positionCounter < 27; positionCounter++) {
51+
// scroll one position left:
52+
lcd.scrollDisplayLeft();
53+
// wait a bit:
54+
delay(200);
55+
}
56+
57+
// scroll 27 positions (display length + string length) to the right:
58+
for (int positionCounter = 0; positionCounter < 27; positionCounter++) {
59+
// scroll one position right:
60+
lcd.scrollDisplayRight();
61+
// wait a bit:
62+
delay(200);
63+
}
64+
}
65+

0 commit comments

Comments
 (0)