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.

Monday, December 26, 2016

LED strip lights gradual fader




 

This LED fader circuit requires a Arduino device and a LED strip tape that is RGB colored. The photo on the side shows the cluttered breadboard holding the Arduino nano, mosfets and the LM7805 regulator. It is recommended to solder the components and solder a socket for the Arduino Nano onto a PCB board to maintain proper electrical connect. Typical application for this light circuit are Christmas Lights (which this was used for) and indoor house light decorations. The LED tape used here is a 5 metre roll of 5050 LED lights which was powered by a 12V 3 Amp power supply. The Arduino code cycles through many colors and the rate of change can be changed by changing the delay value in the code.
  The following picture shows the entire circuit diagram: 

Below is the Arduino Code that I found:

Change the integers of the orange highlighted part to change the pinouts of the Arduino
Change the integers of the yellow highlighted part to change the changes of color pattern
Change the integer of the turquoise highlighted part to change the speed of change

const int redled = 11;
const int greenled = 10;
const int blueled = 9;

void setup() {
  setColourRgb(0,0,0);
}

void loop() {
  unsigned int rgbColour[3];

  rgbColour[0] = 0;
  rgbColour[1] = 0;
  rgbColour[2] = 0;

for (int decColour = 0; decColour < 3; decColour += 1) {
int incColour = decColour == 2 ? 0 : decColour + 1;
    for(int i = 0; i < 255; i += 1) {
      rgbColour[decColour] -= 1;
      rgbColour[incColour] += 1;
   
      setColourRgb(rgbColour[0], rgbColour[1], rgbColour[2]);
      delay(20);
    }
  }
}

void setColourRgb(unsigned int red, unsigned int green, unsigned int blue) {
  analogWrite(redled, red);
  analogWrite(greenled, green);
  analogWrite(blueled, blue);

 }