-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharduino_lcd_display_example_code.ino
More file actions
154 lines (144 loc) · 3.13 KB
/
Copy patharduino_lcd_display_example_code.ino
File metadata and controls
154 lines (144 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
Arduino DS18B20
Created: 04/20/2016
By Gus
Modified N/A
By Gus
https://arduinomylifeup.com/
*/
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
lcd.print("hello, world!");
}
void loop() {
delay(2000);
lcd.clear();
autoscrollExample();
lcd.clear();
cursorExample();
lcd.clear();
blinkExample();
lcd.clear();
displayOffExample();
lcd.clear();
scrollExample();
lcd.clear();
textDirectionExample();
}
void autoscrollExample(){
lcd.print("Auto Scroll!");
delay(2000);
lcd.clear();
lcd.setCursor(16, 1);
lcd.autoscroll();
for (int thisChar = 0; thisChar < 10; thisChar++) {
lcd.print(thisChar);
delay(500);
}
//No Auto Scroll Example
lcd.noAutoscroll();
lcd.clear();
lcd.print("No Auto Scroll!");
delay(2000);
lcd.clear();
// set the cursor to (0,0):
lcd.setCursor(0, 0);
for (int thisChar = 0; thisChar < 10; thisChar++) {
lcd.print(thisChar);
delay(500);
}
}
void cursorExample(){
lcd.print("Cursor On!");
// Turn on the cursor:
lcd.cursor();
delay(3000);
// Turn off the cursor:
lcd.clear();
lcd.print("Cursor Off!");
lcd.noCursor();
delay(3000);
}
void blinkExample(){
lcd.print("Blinking On!");
// Turn on the blinking cursor:
lcd.blink();
delay(3000);
lcd.clear();
// Turn off the blinking cursor:
lcd.print("Blinking Off!");
lcd.noBlink();
delay(3000);
}
void displayOffExample(){
lcd.print("Display On!");
delay(2000);
// Turn off the display:
lcd.noDisplay();
delay(2000);
// Turn on the display:
lcd.display();
delay(2000);
}
void scrollExample() {
lcd.print("Scroll Right!");
delay(3000);
lcd.clear();
lcd.print("GO!");
// scroll 29 positions (string length + display length) to the right
// to move it offscreen right:
for (int positionCounter = 0; positionCounter < 18; positionCounter++) {
// scroll one position right:
lcd.scrollDisplayRight();
// wait a bit:
delay(250);
}
lcd.clear();
lcd.print("Scroll Left!");
lcd.clear();
lcd.setCursor(16, 0);
lcd.print("GO!");
// scroll 16 positions (display length + string length) to the left
// to move it back to center:
for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(250);
}
// delay at the end of the full loop:
delay(2000);
}
void textDirectionExample(){
lcd.print("Text Direction!");
delay(2000);
lcd.clear();
lcd.cursor();
int thisChar = 'a';
while(thisChar <= 'z'){
// reverse directions at 'm':
if (thisChar == 'm') {
// go right for the next letter
lcd.rightToLeft();
}
// reverse again at 's':
if (thisChar == 's') {
// go left for the next letter
lcd.leftToRight();
}
// print the character
lcd.write(thisChar);
// wait a second:
delay(250);
// increment the letter:
thisChar++;
}
// go to (0,0):
lcd.home();
// start again at 0
thisChar = 'a';
}