Introduction: Bluetooth RGB Lights With Arduino

Hello there! Today we are going to produce a cool and colorful project where we will be using the arduino UNO microcontroller to control an rgb LED via Bluetooth. In simple terms, we're going to control an LED from our phone! While for now we are only using one LED, it is easy to attach an rgb strip of LEDs to give a greater effect!

You

Step 1: Step 1: Get Your Parts

So to start this project you're gonna need some stuff

1. Arduino Starter Kit

2. HC-05

or...

1. Arduino UNO

2. HC-05

3. 3 x 220 ohm resistor

4. Jumper cables

5. RGB LED

6.Breadboard

NOTE: THE LIGHT ONLY REACTS TO ANDROID SIGNALS AS THE BLUETOOTH MODULE IS NOT SUPPORTED BY iOS FIRMWARE

Step 2: Step 2: Prepare Your Code

#include SoftwareSerial

BLU(0,1);

#define redPin 6 //whichever pin is connected to the red node of the rgb LED

#define greenPin 3 //whichever pin is connected to the green node of the rgb LED

#define bluePin 5 //whichever pin is connected to the blue node of the rgb LED

void setup() {

//Serial setup

Serial.begin(9600);

Serial.println("-= HC-05 Bluetooth RGB LED =-");

BLU.begin(9600);

BLU.println("-= HC-05 Bluetooth RGB LED =-");

pinMode(4, OUTPUT);

digitalWrite(4,HIGH);

pinMode(redPin, OUTPUT);

pinMode(greenPin, OUTPUT);

pinMode(bluePin, OUTPUT);

setColor(255, 0, 0); // calibration sequence, red 0.5s, green 0.5s, blue 0.5s and white

delay(500);

setColor(0, 255, 0);

delay(500);

setColor(0, 0, 255);

delay(500);

setColor(255, 255, 255);

}

void loop() {

while (BLU.available() > 0) {

int redInt = BLU.parseInt();

int greenInt = BLU.parseInt();

int blueInt = BLU.parseInt();

redInt = constrain(redInt, 0, 255);

greenInt = constrain(greenInt, 0, 255);

blueInt = constrain(blueInt, 0, 255);

if (BLU.available() > 0) {

setColor(redInt, greenInt, blueInt);

Serial.print("Red: ");

Serial.print(redInt);

Serial.print(" Green: ");

Serial.print(greenInt);

Serial.print(" Blue: ");

Serial.print(blueInt);

Serial.println();

BLU.flush();

}

}

}

void setColor(int red, int green, int blue) { // function for colour coding

analogWrite(redPin, red);

analogWrite(greenPin, green);

analogWrite(bluePin, blue);

}

Copy this code. It contains code that reacts to Bluetooth signals sent via an android app.

Step 3: Step 3: Assemble the Circuit

Connect the tx and rx,(1,0) to the tx and rx outlets on the HC-05 bluetooth module, respectively. Connect the 5v output and GND to the + and - on the breadboard and connect to the 5v and GND terminals on the module. On your rgb LED, find the pins for Red, Green and Blue, refer to your datasheet or look up the model no. Connect these pins to PWM I/O headers, indicated by a '~' before the no. PWM stands for Pulse Width Modulation and allows you to vary the amount of signal emitted, so we can mix levels of red, green and blue. They control the strength of the signal through high speed oscillations. Replace the pwm no.s in the code before. If you connected red to pin 9, change the #define on line 3 to 9 so the red is defined as 9, likewise for the others. For each connection to a colour pin, red green or blue, attach a 220 ohm resistor in series.

Step 4: Step 4: the App

Since the Project only works on android,

https://play.google.com/store/apps/details?id=appi...

this app manages the rgb ratios in a nicely modelled wheel, it can be made in MIT Appinventor but these developers have kindly done that for us so just go ahead and download it, or make your own.

Once you're in, turn on your phone's Bluetooth, the HC-05 should be blinking rapidly. Tap the Connect button, which will show you a list of devices, tap the HC-05 icon and connect.

Time for testing...

Step 5: Step 5: DONE!... Well Not Really

This project is done, however I would like to add that no project is ever complete, the project to make a good phone still continues today. This project shows that it is possible to control the hue and color of an rgb led wirelessly, this can be applied to a strip of rgb leds to use in your room //hint,hint,hint.

WELL DONE to you too for following along as well. Please give this project a vote for the Rainbows Contest

Colors of the Rainbow Contest

Participated in the
Colors of the Rainbow Contest