Control Fan And Light Using Mobile Bluetooth
char data=0;
void setup() {
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);
pinMode(12, OUTPUT);
Serial.begin(9600);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(10,HIGH);
digitalWrite(12,HIGH);
}
void loop() {
if(Serial.available())
{
data=Serial.read();
if(data=='a')
digitalWrite(7,LOW);
else if(data=='b')
digitalWrite(7,HIGH);
if(data=='c')
digitalWrite(8,LOW);
else if(data=='d')
digitalWrite(8,HIGH);
if(data=='e')
digitalWrite(10,LOW);
else if(data=='f')
digitalWrite(10,HIGH);
if(data=='g')
digitalWrite(12,LOW);
else if(data=='h')
digitalWrite(12,HIGH);
}
}
0 Comments