Saturday, December 31, 2016

Controlling lights with Bluetooth and Arduino



This simple design allows for a user to control their LED's or lights with the use of a relay. The circuit is pretty simple in which, there are only a couple of components; the Bluetooth module- the HC-06 , the Arduino module like a mega, Uno, nano or mini and extensions like a relay and transistor. The circuit can be used in many scenarios like wireless controlled appliances, room lights, fans and etc. As well these Bluetooth modules are cheap if bought online.
The photo on the left shows the HC-06 module with 4 pin-outs.

The photo below shows the circuit design:

Below is the simple code for Arduino:
For the blue highlight, change the integer value to change the pin-out used for the Arduino
Add multiple pinMode for more pins controlled

For the green highlight, change the character value to change the character eg. (1,2,a,b,c) needed to be received by the BT module to do an operation

For the yellow highlight, you can write more operation that it does if the character is received.

You can copy and write more jobs that the Arduino will do if a character is received.

#include <SoftwareSerial.h>
SoftwareSerial BT(10, 11);
void setup()
{
  pinMode(13, OUTPUT);
//eg.  pinMode(12, OUTPUT);
//eg. pinMode(11, OUTPUT);

  BT.begin(9600);
}
char a;
void loop()
{
  if (BT.available())
  {
    a=(BT.read());
    if (a=='1')
    {
      digitalWrite(13, HIGH);
    }
 
     if (a=='2')
    {
      digitalWrite(13, LOW);
    }

//Example of more code
//     if (a=='3')
// {
//    digitalWrite(12, LOW);
// }

//     if (a=='4')
//   {
//     digitalWrite(12, LOW);
//   }

  }

}


FOR THE APPLICATION USED TO CONTROL THE BLUETOOTH CIRCUIT
Download applications like "Bluetooth terminal" or "Arduino BlueControl" 
*Search up on google play store

In bluetooth terminal, you type in the value that you assigned for an operation and send.

In Arduino BlueControl, you can have variety of ways to control the module, but you would assign a button or arrow to the value that you assigned for an operation.