-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArduino code
180 lines (138 loc) · 2.66 KB
/
Arduino code
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#include <LiquidCrystal.h>
const int rs = 2;
const int en = 3;
const int d4 = 4;
const int d5 = 5;
const int d6 = 6;
const int d7 = 7;
const int L1 = 8;
const int L2 = 9;
const int L3 = 10;
const int L4 = 13;
const int pb = 11;
const int echo=A0;
const int trig=A1;
const int echo1=A2;
const int trig1=A3;
const int buzzer = 12;
long duration;
int distCM;
long duration1;
int distCM1;
int count_crocin=1;
int count_flexon=10;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int h = 00;
int m = 4;
int s = 55;
int flag = 0;
int TIME = 0;
const int hs = 0;
const int ms = 1;
int state1 = 0;
int state2 = 0;
void setup()
{
lcd.begin(16, 2);
pinMode(hs, INPUT_PULLUP);
pinMode(ms, INPUT_PULLUP);
pinMode(L1, OUTPUT);
pinMode(L2, OUTPUT);
pinMode(L3, OUTPUT);
pinMode(L4, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(pb, INPUT_PULLUP);
Serial.begin(9600);
pinMode(echo, INPUT);
pinMode(trig, OUTPUT);
pinMode(echo1, INPUT);
pinMode(trig1, OUTPUT);
}
void loop()
{
empty();
int v = digitalRead(pb);
lcd.setCursor(0, 0);
s = s + 1;
lcd.print("TIME:");
lcd.print(h);
lcd.print(":");
lcd.print(m);
lcd.print(":");
lcd.print(s);
if (flag == 24)
flag = 0;
delay(1000);
lcd.clear();
if (s == 60)
{
s = 0;
m = m + 1;
}
if (m == 60)
{
m = 0;
h = h + 1;
flag = flag + 1;
}
if (h == 24)
{
h = 0;
}
lcd.setCursor(0, 1);
if (h == 0 && m == 5)
{
// 1st led
if (s <= 10 )
{
digitalWrite(L1, HIGH);
digitalWrite(buzzer, HIGH);
lcd.print("Crocin");
}
}
if (v == 0)
{
digitalWrite(L1, LOW);
digitalWrite(buzzer, LOW);
}
if (h == 0 && m == 6)
{
// 2nd led
if (s<=10)
{
digitalWrite(L2, HIGH);
digitalWrite(buzzer, HIGH);
lcd.print("Flexon");
count_flexon=count_flexon-1;
}
}
if (v == 0)
{
digitalWrite(L2, LOW);
digitalWrite(buzzer, LOW);
}
}
void empty(){
//led4
digitalWrite(trig, LOW);
digitalWrite(trig, HIGH);
digitalWrite(trig, LOW);
duration = pulseIn(echo, HIGH);
distCM= duration*0.034/2;
if (distCM >=10) {
digitalWrite(L4, HIGH);
} else {
digitalWrite(L4, LOW);
}
//led5
digitalWrite(trig1, LOW);
digitalWrite(trig1, HIGH);
digitalWrite(trig1, LOW);
duration1 = pulseIn(echo1, HIGH);
distCM1= duration1*0.034/2;
if (distCM1 >=10) {
digitalWrite(L3, HIGH);
} else {
digitalWrite(L3, LOW);
}
}