Control RGB LED using Bluetooth and Arduino

Want to change the colour of your RGB LED, with your smartphone? Then this tutorial will show you how you can use Bluetooth and Arduino to change the Hue of your LED wireless in this tutorial we modulate the PWM duty cycle to produce different colours from your LED.To send a desired colour of your choice, we use a smartphone application, which allows you choose colours from a colour gradient palette, the data is then sent over a serial Bluetooth connection with Arduino and the Arduino thus produces the colour for you.Lets Start!!

Things you need:

  •  Arduino
  •  Bluetooth Module(HC-05/06)
  •  RGB LED
  •  Smartphone
  •  Wires

Arduino RGB Led Code

At the start, we declare pin 6,5 and 3 as are output pins to be connected to the Red, Green and Blue terminals of LED and 0 and 1 pins as RX and TX of Bluetooth Module.The code consists a function void setcolour(int red,int green,int blue) ,which has three parameters for three colours,these parameters accept integer values from 0 to 255,where 0 represents 0% PWM Duty cycle and 255 represents 100% Duty cycle.

PWM signal
PWM signal
#include <SoftwareSerial.h>

SoftwareSerial BLU(0,1);

#define redPin 6
#define greenPin 3
#define bluePin 5

void setup()
  //Serial setup
  Serial.println("-= HC-05 Bluetooth RGB LED =-");
  BLU.println("-= HC-05 Bluetooth RGB LED =-");
  pinMode(4, OUTPUT);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);

  setColor(255, 0, 0);
  setColor(0, 255, 0);
  setColor(0, 0, 255);
  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(" Green: ");
      Serial.print(" Blue: ");


void setColor(int red, int green, int blue)
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);

 Wiring up the Circuit

After uploading the code lest start for connections.First, connect the R G and B terminals to the pins 6,5 and 3 with a resistor in series with each terminal.If you have a Common cathode, connect the remaining fourth terminal to the Ground, If its a common anode the connect the remaining terminal to the 5v pin.

Module  Arduino





Arduino rgb led schematics
Arduino RGB led schematics

Setting up your Smartphone

        Download the below application and Install it.After installing connect the Application to your Bluetooth Module while your whole circuit is powered on.(Password for HC-05 is 1234)

        After the connection is established select any colour from the colour palette, LED should light up with the Respective colour.

Watch my Youtube video on this Subject

14 thoughts on “Control RGB LED using Bluetooth and Arduino

  1. una pregunta amigo … compre el modulo bluetooth y ya hice la conexion pero no lo lee el dspositivo , mi dispositivo es i phone , no hay ningun problema

  2. hello, when i connect and load the program, then i connect with my phone. why can not change the color in the apps? plz help

  3. hola, al copiar la programacion al programa de arduino 1.6.7 me dice error en algunas cosas de la programacion
    que debo hacer?

Leave a Reply

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

Show Buttons
Hide Buttons