Bluetooth Controlled RGB LED strip

RGB LED strips such as this are available for a low price.They are generally bundled with a IR controller and a power supply to power the LEDs and to change the color ,display various colour sequences etc.The IR Receiver is  similiar to those used in TV and requires line-of-sight for reliable operation . I wanted the strip to be Controllable via a PC or a Mobile Phone.So I decided to make my own RGB LED strip Controller and to enable wireless control  i used Bluetooth technology.The device can be controlled using a PC or a mobile phone with Bluetooth having a suitable graphical  user interface.

The Hardware needed for this build is pretty simple and uses commonly found devices and may be salvaged from old electronics.

  1. Atmega8L-8PU 8-bit AVR microcontroller
  2. LM1117-3.3 3.3V LDO regulator
  3. IRF640 N-Channel MOSFET(salvaged from an old Uninterrupted Power Supply-Thanks Kushal for that Dead UPS! )
  4. Connecting wires ,Berg strips,etc.
  5. 12v 1A+Wall wart.

The Firmware for the ATmega8L micrcontroller was developed with Arduino 0023 and also with Arduino 1.0 (Can be downloaded for your OS of choice from HERE).The GUI for the Windows PC was Developed using the GTK+ toolkit using the python bindings available via pyGTK(Get it from here).The GUI was designed for running on nokia s60 devices using  pyS60.

The arduino Firmware

The arduino is an awesome prototyping platform.Churning out prototypes from Ideas is very fast since all the hardware and other functions are pretty much abstracted out and only the Application Logic needs to be implemented.

The Firmware performs the following basic functions.Handle the communication routines,Control the LED brightness for each of the Colors RED,GREEN and BLUE and also be able to display the various sequences of colors of light.

I have a Arduino Duemilanove that came with an Atmega328P processor onboard.The Atmega 328P would have been an overkill for this project so i decided to replace it with an Atmega8L.The mega8 has only 3 v/s 6 PWM  channels and 8K v/s 32K of flash program memory of the mega328.To verify the firmware I set up a simple testbench with three LEDs one each of RED GREEN and BLUE LEDs plugged into a breadboard connected to the Digital pins 9,10,11 of the arduino.These Correspond to the PWM Pins on the atmega8. The Communications with the controller was tested with the standard serial port given by the FTDI interface of the arduino.

Once The test bench was setup I could move on to Actually Writing the Firmware.The Setup section consists of all the PWM pins being set as Output and the Serial Port opened to Communicate at 9600 Baud.The Main while Loop has a Non-blocking delay section in which the Functions are updated at a User changeable delay.The more the delay the more slowly the color transition takes place and viz.This is necessary because if a delay is not present then the transitions would be so fast that it would appear as if the LEDs are blinking.I have NOT used the default delay function of the arduino library because of it blocking nature(Here’s a good article about Non-blocking code).The delay would block the processor by executing a number of instructions with a known execution time to get the specified time delay and only then execute the next instruction.This blocking delay would cause problems when data arrives at the serial port and the processor is busy executing the delay.Hence the data will be missed by the processor or will be processed only when the delay loop completes execution thus introducing lags between the user giving input and the suitable function being executed.Non-blocking Delay is hence used to prevent these problems and to provide reliable communication.And Precisely for this reason I have avoided Blocking codes in my Firmware.

The CellPhone GUI

The Cellphone GUI is a  pyS60 script with five consecutive dialog boxes for mode selection,red value,green value,blue value and the update delay value  respectively.The mode selection selects one of three modes.Mode 0 is the default mode  will fire up if no bluetooth device is connected for control .In this mode the entire colour spectrum is traversed starting from red end of the spectrum.The transition goes on in a infinte loop.Mode 2 is a mode where each color namely Red,Green,Blue and White Respectively “breathe” i.e. the intensity of each color goes from zero to maximum and back to zero.Check out the Video to see it in action.The Mode three is the Color Chooser Mode. In this mode the User can choose the color.Set the value of the respective color from 0 for completely off to 255 for fully bright.

Also the Update delay can be set in milliseconds.This is used for setting the Delay Between Each color transition.the more the dealy the more slower will be the colour change. An update delay of around 5 to 20 milliseconds has a pleasing effect.

[Screenshot]The Pys60 Script Running on my S60 3rd Edition Nokia N78.

The PC GUI.

The PC gui was created Using PyGTK and UImanager Tools for GUI Creation. The PC GUI runs well on Windows (and probably also on Linux).I have tested it on my Windows Seven Home Premium 64-bit laptop .For Running the Application on Linux Small Amount of changes will have to be made ,Like changing the serial port label(on linux the PORT variable would be something like  dev/ttyUSB0) etc. But other than that it would work fine on linux too.The GUI has three sliders for Color selection and a Bunch of radio Buttons for Mode selection.The Sliders are active only in the color selection mode.Check out the Source code included in the Zip file attached

[Screenshot]The Python Gui running on A win7 Home Premium x64 Machine

Hardware Design

the Hardware basically consists of a Atmega8L Microcontroller (with an Arduino Bootloader on-board which i have  included in the sources.zip file) and three  IRF640 N-channel MOSFETs ,One Each for Driving Each  Color on the RGB LED strip .There’s also Lm1117 3.3V power regulator for powering up the Logic and a Berg connector for connecting the RX,TX,GND and VCC lines of the Bluetooth Module with the Atmega.I did Not make a schematic since i did not want to etch a PCB.Instead i just built the entire circuit on a perf-board and used flexible wire to build the circuit.The Entire Circuit is designed to be powered by an 12V DC Supply.I checked the Power  Consumption of the entire circuit with a Multimeter and it was found to be around 1Amp.I used a 12v 2 Amp SMPS based supply.

I made My prototype on a perfboard here’s a Pic of the Top Side.

And the Bottom Side

Working on a PCB using toner tranfer technique to finalise the prototype. All the Python Source Codes and the Hardware schematics and the Layout Diagrams in Eagle Format are included in the attached Zip File .Feedback is appreciated!(Note:a ULN2803 and a 7805 are some extra components on the PCB shown above that i tried out during testing.But are not necessary in this circuit).

Here are some pics of the project in action.

Download all the required Source codes and the hardware design files from here.

UPDATE: Uploaded all the source Code to github

9 thoughts on “Bluetooth Controlled RGB LED strip

  1. Surajsays

    Awesome work Murli !

    Reply
    1. murlidharshenoysays

      Thanks Man! :)

      Reply
  2. virgosays

    Really Nice, Did you get the RGB strips locally ( as the ebay link doesn’t ship to india and is also bit costly ). >

    Reply
    1. murlidharshenoysays

      yup got it from a local shop…was actually trying first on ebay but found a better deal locally :)

      Reply
      1. virgosays

        where did you got it from in mumbai , Can you share the place and price. I am from mumbai too and would like to buy.

        Reply
        1. murlidharshenoysays

          you can get it from cirkit electronics at lamington road.

          Reply
  3. Murali vignesh..says

    its too creative man..u r genius..

    Reply
    1. murlidharshenoysays

      Thanks :)

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *