-
Notifications
You must be signed in to change notification settings - Fork 0
/
liquidCrystalOneSheeldTemperatureSketch.ino
87 lines (67 loc) · 1.66 KB
/
liquidCrystalOneSheeldTemperatureSketch.ino
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
#define CUSTOM_SETTINGS
#define INCLUDE_TERMINAL_SHIELD
#define INCLUDE_TEMPERATURE_SENSOR_SHIELD
/* Include 1Sheeld library. */
#include <OneSheeld.h>
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
/* Reserve a byte for Temperature value. */
int tempValue = 0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
printNew("OneSheeld init...",0);
/* Start communication. */
OneSheeld.begin();
delay(1000);
printNew("Successful!",0);
delay(1000);
printNew("Get Temp.", 1);
delay(3000);
}
void loop() {
/* Always get Temperature sensor value. */
tempValue = TemperatureSensor.getValue();
printValues("Temperature:", tempValue);
Terminal.println(tempValue);
}
void printNew(String buff, int vert_position) {
lcd.clear();
if (vert_position % 2 == 0) {
vert_position = 0;
} else {
vert_position = 1;
}
lcd.setCursor(0, vert_position);
lcd.print(buff);
}
void printNew(String buff, int hor_position, int vert_position) {
lcd.clear();
if (vert_position % 2 == 0) {
vert_position = 0;
} else {
vert_position = 1;
}
if ((hor_position > 16) || (hor_position < 0)) {
vert_position = 0;
}
lcd.setCursor(hor_position, vert_position);
lcd.print(buff);
}
void printValues(String buff1, String buff2){
lcd.clear();
lcd.setCursor(0,0);
lcd.print(buff1);
lcd.setCursor(5,0);
lcd.print(buff2);
}
void printValues(String buff1, int buff2){
lcd.clear();
lcd.setCursor(0,0);
lcd.print(buff1);
lcd.setCursor(14,1);
lcd.print(buff2, DEC);
delay(500);
}