Skip to content

Commit a78a4d2

Browse files
authored
Add files via upload
0 parents  commit a78a4d2

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

lcd.ino

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#include <LiquidCrystal.h>
2+
3+
byte upLeft0[8] = {
4+
B00000,
5+
B00000,
6+
B00000,
7+
B00000,
8+
B00000,
9+
B01111,
10+
B01111,
11+
B01111,
12+
};
13+
14+
byte upLeft1[8] = {
15+
B00010,
16+
B00100,
17+
B00010,
18+
B00001,
19+
B00000,
20+
B01111,
21+
B01111,
22+
B01111,
23+
};
24+
25+
byte upRight0[8] = {
26+
B00000,
27+
B00000,
28+
B00000,
29+
B00000,
30+
B00000,
31+
B11100,
32+
B11110,
33+
B11101,
34+
};
35+
36+
byte upRight1[8] = {
37+
B01000,
38+
B00100,
39+
B01000,
40+
B10000,
41+
B00000,
42+
B11100,
43+
B11110,
44+
B11101,
45+
};
46+
47+
byte lowLeft[8] = {
48+
B01111,
49+
B01111,
50+
B01111,
51+
B00111,
52+
B00011,
53+
B00000,
54+
B00000,
55+
B00000,
56+
};
57+
58+
byte lowRight[8] = {
59+
B11101,
60+
B11101,
61+
B11101,
62+
B11110,
63+
B11000,
64+
B00000,
65+
B00000,
66+
B00000,
67+
};
68+
69+
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);
70+
71+
const int PUSHBTN = 9;
72+
73+
int state = 0;
74+
int reading;
75+
int previous = 1;
76+
77+
bool fresh = false;
78+
79+
String coffeMsg = " No Coffee :(";
80+
81+
void setup() {
82+
// Serial.begin(9600);
83+
lcd.begin(16, 2);
84+
lcd.createChar(7, upLeft0);
85+
lcd.createChar(8, upRight0);
86+
lcd.createChar(9, lowLeft);
87+
lcd.createChar(10, lowRight);
88+
lcd.createChar(11, upRight1);
89+
lcd.createChar(12, upLeft1);
90+
pinMode(PUSHBTN, INPUT);
91+
}
92+
93+
void loop() {
94+
reading = digitalRead(PUSHBTN);
95+
// Serial.println(reading);
96+
lcd.setCursor(2, 0);
97+
lcd.print(coffeMsg);
98+
lcd.setCursor(3, 1);
99+
lcd.print("12:00 Wed");
100+
printCoffee();
101+
if (reading == 1) {
102+
toggleCoffeMsg();
103+
}
104+
previous = reading;
105+
}
106+
107+
void toggleCoffeMsg() {
108+
lcd.setCursor(2, 0);
109+
coffeMsg = " ";
110+
if(fresh) {
111+
coffeMsg = "Fresh Coffee !";
112+
} else {
113+
coffeMsg = " No Coffee :( ";
114+
}
115+
fresh = !fresh;
116+
}
117+
118+
void printCoffee() {
119+
lcd.setCursor(0, 0);
120+
lcd.write(7);
121+
lcd.setCursor(1, 0);
122+
lcd.write(11);
123+
lcd.setCursor(0, 1);
124+
lcd.write(9);
125+
lcd.setCursor(1, 1);
126+
lcd.write(10);
127+
// delay(500);
128+
// lcd.setCursor(1, 0);
129+
// lcd.write(8);
130+
// lcd.setCursor(0, 0);
131+
// lcd.write(12);
132+
// delay(500);
133+
}

0 commit comments

Comments
 (0)