Phone Controlled RBG LED Lights

by kerimil in Circuits > LEDs

20517 Views, 59 Favorites, 0 Comments

Phone Controlled RBG LED Lights

rgbmain.jpg
A simple phone controlled RBG LED light. It communicates over bluetooth. All you need is an RBG LED, 3 resistors, a bluetooth module (like HC-05), arduino board and a mobile phone with bluetooth.




Wiring details and as well as links to the app here -> forum.arduino.cc/index.php?top­ic=148853.msg1408773#msg140877­3

Wiring Details

rgb_bb.jpg
Here is wiring. Make sure you double check your the datasheet of the bluetooth module that you have. You just need to connect VCC, ground and TX pin on the module to 5V+, GND and RX pin on the arduino board. Some modules are only 3.3V tolerant so make sure you READ THE DAMN datasheet first ;-)

Arduino Code

rgbmain.jpg
Here is arduino code - it's a slightly modified version of an example sketch that comes with arduino IDE - the one that relies on parseInt funtion.

Note that I used baud rate of 19200 because that's the default rate for my bluetooth module. It usually takes less time to just change it in arduino sketch rather than use AT commands to change baud rate of the module so READ THE DAMN DATASHEET and check what's the default baud rate of your module. Also note that the module has to be working as 
master so if it does not work check if yours is set as master.


anyway hte code is below ->

// pins for the LED:
const int redPin = 9;
const int greenPin = 10;
const int bluePin = 11;

void setup() {
  // initialize serial:
  Serial.begin(19200);
  // make the pins outputs:
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
  Serial.setTimeout(50);

}

void loop() {
  // if there's any serial available, read it:
  while (Serial.available() > 0) {

    // look for the next valid integer in the incoming serial stream:
    int red = Serial.parseInt();
    // do it again:
    int green = Serial.parseInt();
    // do it again:
    int blue = Serial.parseInt();

    // look for the newline. That's the end of your
    // sentence:
    if (Serial.read() == '\n') {
      // constrain the values to 0 - 255 and invert
      // if you're using a common-cathode LED, just use "constrain(color, 0, 255);"
      red = 255 - constrain(red, 0, 255);
      green = 255 - constrain(green, 0, 255);
      blue = 255 - constrain(blue, 0, 255);

      // fade the red, green, and blue legs of the LED:
      analogWrite(redPin, red);
      analogWrite(greenPin, green);
      analogWrite(bluePin, blue);

      // print the three numbers in one string as hexadecimal:
     
    }
  }
}

Android App

rgb_appinventor.jpg
Here you can download both the app and the source file that you can upload into app inventor to modify it >
https://drive.google.com/folderview?id=0B_PfPoEotOF8N2JwT3RSX011SjQ&usp=sharing
the app has .apk extension
the source file has .zip extension





TROUBLESHOOTING of this project and your own modified versions of the app.
If something does not work read the entire instructable and the datasheet of your module again. Make sure TX pin on the module is connected to RX pin on arduino board. Make sure you're powering the module with voltage it needs.

If you still can't work this out get a bluetooth dongle if your desktop/laptop doesn't have inbuilt bluetooth, and download putty (or just use serial monitor that comes with arduino IDE). First, connect the phone to the computer, open putty and see what the app sends when you move sliders. Then test the other half of the project - connect from the computer (using bluetooth of course) to the module and again open putty/serial monitor. Enter commands manually, make sure it sends a newline at the end of each command and see if the aruduino board responds. These two procedure should explain a lot and help you find out whether the phone/app is the problem or the arduino + BTmodule.