-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSH.ino
336 lines (269 loc) · 5.17 KB
/
DSH.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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/* code for no activity:
// HOMESHH - Capstone Prototype
// by Niam Moltta
const int Green =12;
const int Blue =11;
const int Red =13;
void setup()
{
pinMode(Green, OUTPUT);
pinMode(Blue, OUTPUT);
pinMode(Red, OUTPUT);
}
void loop() {
//Red
digitalWrite(Red, HIGH);
digitalWrite(Blue, LOW);
digitalWrite(Green, LOW);
delay(1000);
//Green
digitalWrite(Red, LOW);
digitalWrite(Blue, LOW);
digitalWrite(Green, HIGH);
delay(1000);
//Blue
digitalWrite(Red, LOW);
digitalWrite(Blue, HIGH);
digitalWrite(Green, LOW);
delay(1000);
//Magenta
digitalWrite(Red, HIGH);
digitalWrite(Blue, HIGH);
digitalWrite(Green, LOW);
delay(1000);
//Cyan
digitalWrite(Red, LOW);
digitalWrite(Blue, HIGH);
digitalWrite(Green, HIGH);
delay(1000);
//Yellow
digitalWrite(Red, HIGH);
digitalWrite(Blue, LOW);
digitalWrite(Green, HIGH);
delay(1000);
}
*/
// Activity Code:**********************************************************************:
// HomeShh - IoT Specialization Capstone Project
// Smart Home for deaf people
// by Niam Moltta.
const int G =12;
const int B =11;
const int R =13;
const int S = 10;
const int A = 8;
const int C = 7;
const int D = 6;
const int K = 5;
const int M = 9;
const int E = 4;
const int F = 3;
const int L = 2;
const int Y = A3;
const int P = A2;
const int V = A0;
const int W = A1;
int s = 0;
int c = 0;
int ms = 0;
int db = 0;
void setup()
{
pinMode(G, OUTPUT);
pinMode(B, OUTPUT);
pinMode(R, OUTPUT);
pinMode(S, OUTPUT);
pinMode(M, OUTPUT);
pinMode(A, OUTPUT);
pinMode(C, OUTPUT);
pinMode(D, OUTPUT);
pinMode(F, OUTPUT);
pinMode(L, OUTPUT);
Serial.begin(9600);
pinMode(K, INPUT);
pinMode(V, INPUT);
pinMode(E, INPUT);
pinMode(W, INPUT);
pinMode(Y, INPUT);
pinMode(P, INPUT);
Nothing();
OffS();
digitalWrite(M, LOW);
digitalWrite(L, LOW);
digitalWrite(F, LOW);
digitalWrite(S, LOW);
noTone(S);
}
void loop() {
//Car present
long car = digitalRead(E);
if(car == HIGH) {
digitalWrite(L, HIGH);
delay(1000); //time for simulation purposes
}
else
{
digitalWrite(L, LOW);
}
//Fire simulation
s = analogRead(V);
Serial.println("Smoke Signal K");
Serial.println(s);
if (s > 20) {
Fire();
tone(S, 1000);
delay(100);
analogWrite(M, 255);
}
else {
noTone(S);
Nothing();
OffS();
}
ms = analogRead(W);
Serial.println("Smoke Signal G");
Serial.println(ms);
if (ms > 20) {
Fire();
FireS();
tone(S, 1000);
delay(50);
analogWrite(M, 255);
}
else {
noTone(S);
Nothing();
OffS();
}
//Phone simulation
c = analogRead(Y);
Serial.println("call");
Serial.println(c);
if (c == 1023) {
Phone();
PhoneS();
tone(S, 700);
delay(50);
analogWrite(M, 255);
}
else {
noTone(S);
Nothing();
OffS();
}
//Doorbell simulation
db = analogRead(P);
Serial.println("Signal");
Serial.println(db);
if (db == 1023) {
Doorbell();
DoorbellS();
tone(S, 330);
delay(35);
tone(S, 261);
delay(35);
analogWrite(M, 255);
}
else {
noTone(S);
Nothing();
OffS();
}
//Burglar Simulation
long b = digitalRead(K);
if(b == HIGH) {
Robbery();
RobberyS();
tone(S, 440, 1000);
digitalWrite(F, HIGH);
Serial.println(b);
delay(50);
analogWrite(M, 255);
}
else
{
OffS();
noTone(S);
}
}
//RGB**************************//
void Fire() {
//RED!
digitalWrite(R, HIGH);
digitalWrite(B, LOW);
digitalWrite(G, LOW);
}
void Doorbell() {
//GREEN
digitalWrite(R, LOW);
digitalWrite(B, LOW);
digitalWrite(G, HIGH);
}
void Robbery() {
//BLUE
digitalWrite(R, LOW);
digitalWrite(B, HIGH);
digitalWrite(G, LOW);
}
void Noise() { //ABOVE 120db!!!
//MAGENTA (OPTIONAL WITH RASPBERRY PI)
digitalWrite(R, HIGH);
digitalWrite(B, HIGH);
digitalWrite(G, LOW);
}
void Phone() {
//CYAN
digitalWrite(R, LOW);
digitalWrite(B, HIGH);
digitalWrite(G, HIGH);
}
void Nothing() {
//YELLOW
digitalWrite(R, HIGH);
digitalWrite(B, LOW);
digitalWrite(G, HIGH);
}
//END MAIN RGB's**************************
//BEDROOM FAN ALARM RGB
void FireS() {
//RED!
digitalWrite(A, HIGH);
digitalWrite(D, LOW);
digitalWrite(C, LOW);
}
void DoorbellS() {
//GREEN
digitalWrite(A, LOW);
digitalWrite(D, LOW);
digitalWrite(C, HIGH);
}
void RobberyS() {
//BLUE
digitalWrite(A, LOW);
digitalWrite(D, HIGH);
digitalWrite(C, LOW);
}
void NoiseS() { //ABOVE 120db!!!
//MAGENTA (optional for RASPBERRY PI, since this simulator doesn't have microphones)
digitalWrite(A, HIGH);
digitalWrite(D, HIGH);
digitalWrite(C, LOW);
}
void PhoneS() {
//CYAN
digitalWrite(A, LOW);
digitalWrite(D, HIGH);
digitalWrite(C, HIGH);
}
void NothingS() {
//YELLOW
digitalWrite(A, HIGH);
digitalWrite(D, LOW);
digitalWrite(C, HIGH);
}
void OffS() {
digitalWrite(A, LOW);
digitalWrite(D, LOW);
digitalWrite(C, LOW);
}
/* ************************END************************************************************/