Home automation | Control your room lights using your mobile


materials:-

  •   Arduino uno
  •   Bluetooth module
  •   2 channel relay
  •   jumper wires


diagram:-




Connections:-


  • Bluetooth module RX = Arduino TX
  • Bluetooth module TX = Arduino RX
  • Bluetooth GND = Arduino GND
  • Bluetooth VCC/5V = arduino 3.3V
  • Relay IN1 = Arduino pin 12
  • Relay IN2 = Arduino pin 13 
  • Relay 5V = Arduino 5V
  • Relay GND = Arduino GND

Code:-

//https://mrarduinoprojects.blogspot.com
char val;


void setup() {
  pinMode(13, OUTPUT);
  pinMode(12,OUTPUT);
  Serial.begin(9600);

}

void loop() {
  if (Serial.available()) {
    val = Serial.read();
    Serial.println();
  }
  if (val == '1')
  { digitalWrite(13, HIGH);

  }
  else if (val == '2')
  {
    digitalWrite(13, LOW);
  }
  else if (val == '3')
  {
    digitalWrite(12, HIGH);
  }
  else if (val == '4')
  {
    digitalWrite(12, LOW);
  }

  delay(100);
}