-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHome_Automation.ino
67 lines (59 loc) · 1.36 KB
/
Home_Automation.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
#include<SoftwareSerial.h>
#include<LiquidCrystal.h>
LiquidCrystal lcd(7,6,5,4,8,9);
#define TxD 3
#define RxD 2
#define LED_PIN 13
#define PIN_NXT 12
#define PIN_ST 10
SoftwareSerial bluetoothSerial(TxD, RxD);
char c;
int st;
void setup() {
bluetoothSerial.begin(9600);
Serial.begin(9600);
lcd.begin(16,2);
pinMode(LED_PIN, OUTPUT);
pinMode(PIN_NXT, OUTPUT);
pinMode(PIN_ST, INPUT);
lcd.setCursor(0,0);
lcd.print(" TEAM XFINITY ");
// lcd.print(" suri_kumkaran ");
lcd.setCursor(0,1);
// lcd.print(" ROCKS ");
lcd.print(" Presents ");
delay(3000);
lcd.setCursor(0,0);
lcd.print(" Home ");
lcd.setCursor(0,1);
lcd.print(" Automation ");
delay(4000);
lcd.clear();
}
void loop() {
lcd.setCursor(0,0);
lcd.print(" Bluetooth ");
lcd.setCursor(0,1);
st=digitalRead(PIN_ST); //State for detecting Bluetooth is connected or not
Serial.println(st);
if(st)
lcd.print(" Connected ");
else
lcd.print(" Disconnected ");
if(bluetoothSerial.available()){
c = bluetoothSerial.read();
// Serial.println(c);
if(c=='2'){
digitalWrite(LED_PIN, HIGH); //one OFF
}
if(c=='1'){
digitalWrite(LED_PIN, LOW); //one ON
}
if(c=='3'){
digitalWrite(PIN_NXT, LOW); //two ON
}
if(c=='4'){
digitalWrite(PIN_NXT, HIGH); //two OFF
}
}
}