Muhammad_Munir
Published © GPL3+

How to Control AC Load With Bluetooth

Control electric appliances with android phone by using Bluetooth

IntermediateFull instructions provided79
How to Control AC Load With Bluetooth

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Relay (generic)
×4
BD139 Transistor
×1
2.2k resistor
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino Bluetooth Controller

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Code

Arduino
#define r1 5
int relay1 = LOW;
#define r2 6
int relay2 = LOW;
#define r3 7
int relay3 = LOW;
#define r4 8
int relay4 = LOW;

void setup() {
Serial.begin(9600);
    pinMode(r1, OUTPUT); 
    pinMode(r2, OUTPUT);
    pinMode(r3, OUTPUT); 
    pinMode(r4, OUTPUT);
 }

void loop() {
  // put your main code here, to run repeatedly:
 if(Serial.available()>0) 
   {     
      char data= Serial.read(); // reading the data received from the bluetooth module
      switch(data)
      {
        case 'a':
            digitalWrite(r1,0);
            digitalWrite(r2,0);  //all off
            digitalWrite(r3,0);
            digitalWrite(r4,0);
            delay(250);
            break;        
            case 'b':
            relay1 = ~ relay1;
            digitalWrite(r1,relay1);
            delay(250);
            break;
            case 'c':
            relay2 = ~ relay2;
            digitalWrite(r2,relay2);
            delay(250);
            break;
            case 'd':
            relay3 = ~ relay3;
            digitalWrite(r3,relay3);
            delay(250);
            break;
            case 'e':
            relay4 = ~ relay4;
            digitalWrite(r4,relay4);
            delay(250);
            break;
      }
      Serial.println(data);
   }
   delay(50);
}

Credits

Muhammad_Munir

Muhammad_Munir

1 project • 2 followers

Comments