Hardware
1.Arduino UNO
2.HC06 Bluetooth
3.Relay Module
4.Smart phone
5.Wire
Wiring
4 Relay module to Arduino pin
GND >> GND
IN1 >> 2
IN2 >> 3
IN3 >> 4
IN4 >> 5
Vcc >> 5 Volt
Bluetooth
Bluetooth to Arduino
TX -----> 10
RX -----> 11
MIT application
Download and install to your smart phone
VDO
CODE
#include<SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
String state;
int LED1=2;
int LED2=3;
int LED3=4;
int LED4=5;
void setup() {
// put your setup code here, to run once:
mySerial.begin(9600);
Serial.begin(9600); //start serial communication
pinMode(LED1, OUTPUT);//Pin2
pinMode(LED2, OUTPUT);//Pin3
pinMode(LED3, OUTPUT);//Pin4
pinMode(LED4, OUTPUT);//Pin5
digitalWrite(LED1,HIGH);
digitalWrite(LED2,HIGH);
digitalWrite(LED3,HIGH);
digitalWrite(LED4,HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
while (mySerial.available()){ //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = mySerial.read(); //Conduct a serial read
state += c; //Shorthand for voice = voice + c
}
if (state.length() > 0){
Serial.println(state);
if(state == "light on")
{
digitalWrite(LED1,LOW);
}
else if(state == "light off")
{
digitalWrite(LED1,HIGH);
}
if(state == "pump on")
{
digitalWrite(LED2,LOW);
}
else if(state == "pump off")
{
digitalWrite(LED2,HIGH);
}
if(state == "fan on")
{
digitalWrite(LED3,LOW);
}
else if(state == "fan off")
{
digitalWrite(LED3,HIGH);
}
if(state == "heat on")
{
digitalWrite(LED4,LOW);
}
else if(state == "heat off")
{
digitalWrite(LED4,HIGH);
}
state ="";}
}