-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHacsp.ino
More file actions
65 lines (45 loc) · 1.67 KB
/
Hacsp.ino
File metadata and controls
65 lines (45 loc) · 1.67 KB
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
/****************** HOME APPLIANCES CONTROL SYSTEM PROJECT ******************/
/*Coder - Saurabh Sharma*/
/*The following is the code required to be run on arduino to enable control of your
home appliances from a smartphone, please install DIY SmartHome android application
first on your android phone.Please visit DIYhacking.com for detailed instructions on this project.*/
/*This project requires 2 continous rotation servos connected to pins 9 and 10 of arduino*/
byte val;
void setup()
{
Serial.begin(115200);//Change the baud rate value depending on the default baud rate of your bluetooth module, for Bluesmirf-115200 and for JY-MCU-9600
pinMode(2, OUTPUT);//Light1 pin
pinMode(3, OUTPUT);//Light2 pin
pinMode(4, OUTPUT);//Light3 pin
pinMode(5, OUTPUT);//AC pin
pinMode(6, OUTPUT);//Door Lock
}
void loop()
{
int a=0;
if(Serial.available())
{
val=Serial.read();
Serial.println(int(val));//Display received value on Serial Monitor
if(int(val)==49)//Turn Light1 ON
digitalWrite(2,HIGH);
else if (int(val)==50)//Turn Light1 OFF
digitalWrite(2,LOW);
if(int(val)==51)//Turn Light2 ON
digitalWrite(3,HIGH);
else if(int(val)==52)//Turn Light2 OFF
digitalWrite(3,LOW);
if(int(val)==53)//Turn Light3 ON
digitalWrite(4,HIGH);
else if(int(val)==54)//Turn Light3 OFF
digitalWrite(4,LOW);
if(int(val)==55)//Turn AC ON
digitalWrite(5,HIGH);
else if(int(val)==56)//Turn AC OFF
digitalWrite(5,LOW);
if(int(val)==57)//Lock the DOOR
digitalWrite(6,HIGH);
else if(int(val)==48)//Unlock the DOOR
digitalWrite(6,LOW);
}
}