Activated Home Automation Project by using Arduino For Smart Home
Components Required
- Arduino UNO x 1
- HC – 05 Bluetooth Module x 1
- Smart Phone or Tablet x 1
- 2N2222 NPN Transistor x 4
- 12V Relay x 4
- 1 KΩ Resistor x 4
- 1N4007 PN Junction Diode x 4
- Power Supply
- Connecting Wires
- Breadboard (Prototyping Board)
- App for transmitting voice to Bluetooth
Source 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
| <pre>#include <SoftwareSerial.h> const int rxPin = 2; const int txPin = 3; SoftwareSerial mySerial(rxPin, txPin); int ac=4; int light=5; int fan=6; int tv=7; String data; void setup() { Serial.begin(9600); mySerial.begin(9600); pinMode(ac, OUTPUT); pinMode(light, OUTPUT); pinMode(fan, OUTPUT); pinMode(tv, OUTPUT); digitalWrite(ac, LOW); digitalWrite(light, LOW); digitalWrite(fan, LOW); digitalWrite(tv, LOW); } void loop() { int i=0; char ch=0; data= "" ; while (1) { while (mySerial.available()<=0); ch = mySerial.read(); if (ch== '#' ) break ; data+=ch; } Serial.println(data); if (data== "*turn on AC" ) { digitalWrite(ac,HIGH); Serial.println( "ac on" ); } else if (data== "*turn off AC" ) { digitalWrite(ac,LOW); Serial.println( "ac off" ); } else if (data== "*turn on light" ) { digitalWrite(light,HIGH); Serial.println( "light on" ); } else if (data== "*turn off light" ) { digitalWrite(light,LOW); Serial.println( "light off" ); } else if (data== "*turn on fan" ) { digitalWrite(fan,HIGH); Serial.println( "fan on" ); } else if (data== "*turn off fan" ) { digitalWrite(fan,LOW); Serial.println( "fan off" ); } else if (data== "*turn on TV" ) { digitalWrite(tv,HIGH); Serial.println( "tv on" ); } else if (data== "*turn on TV" ) { digitalWrite(tv,LOW); Serial.println( "tv off" ); } else if (data== "*turn on all" ) { digitalWrite(ac,HIGH); digitalWrite(light,HIGH); digitalWrite(fan,HIGH); digitalWrite(tv,HIGH); Serial.println( "all on" ); } else if (data== "*turn off all" ) { digitalWrite(ac,LOW); digitalWrite(light,LOW); digitalWrite(fan,LOW); digitalWrite(tv,LOW); Serial.println( "all off" ); } } |
ไม่มีความคิดเห็น:
แสดงความคิดเห็น