-
Notifications
You must be signed in to change notification settings - Fork 0
/
bt_arduino.ino
60 lines (58 loc) · 1 KB
/
bt_arduino.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
#include <SoftwareSerial.h>
SoftwareSerial BT(0, 1); //TX, RX
String command;
void setup()
{
BT.begin(9600);
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
while (BT.available())
{
delay(10);
char c = BT.read();
command += c;
}
if (command.length() > 0) {
Serial.println(command);
if(command == "light on")
{
digitalWrite(2, HIGH);
}
else if(command == "light off")
{
digitalWrite(2, LOW);
}
else if (command == "lamp on")
{
digitalWrite (3, HIGH);
}
else if ( command == "lamp off")
{
digitalWrite (3, LOW);
}
else if (command == "fan on")
{
digitalWrite (4, HIGH);
}
else if (command == "fan of")
{
digitalWrite (4, LOW);
}
else if (command == "all on")
{
digitalWrite (2, HIGH);
digitalWrite (3, HIGH);
digitalWrite (4, HIGH);
}
else if (command == "off")
{
digitalWrite (2, LOW);
digitalWrite (3, LOW);
digitalWrite (4, LOW);
}
command="";}}
//thankyou- SHUBHAM PARDHI