Introduction: SmartPhone Controlled RGB MOOD Light

About: So basically i am a crazy person, who loves to think the most odd way ever possible,who makes what he thinks and also let other also make those . Check out my crazy projects if you like do follow me :D

Mood lamps are always fascinating for me and is a very good project for starters to start with Arduino.

What is a Mood Lamp ?

Mood lamps are lighting devices that are used to establish a particular feeling or mood within a room. In some cases, this type of lamp may be a small device that is plugged into an outlet and creates points of light near the floor line of the room. Other examples of a mood lamp may be used to illuminate specific points along the walls or cast a soft light over a larger piece of furniture in the room.

Mood lighting differ somewhat from other lamps in that their purpose is not so much practical as aesthetic. Reading lamps for example tend to provide bright light to a given space in order to make it possible to read a book or magazine without creating strain on the eyes. Overhead lighting is used when there is a need to illuminate the majority of the space, such as in a classroom or laboratory. By contrast, a mood lamp is used to help create a specific ambiance within the room as a means of making the space more attractive and welcoming in some manner.

NOTE : THIS Instructables is accepted for rainbow contest do vote if you like the it .

Do subscribe my channel for upcoming videos .

https://www.youtube.com/user/pious67

Step 1: Components

The component list way too small but there are diversity in the list . i actually reviewed three types over the this instructables
anyways the list .

  • Arduino
  • RBG led
  • HC-05
  • Jumpers
  • Bread Board

Comparison of all the variants

RGB led : Easily available in ebay and all radio shack or locals store.

High Color Output. Can be easily power withi arduino .
RGB SMD : This are sold as module i test a common cathode version the seem not to wrk great with arduinos internal power supply.
RGB LED Strip : These are the Best comes with highes color range output with a correct driver you can drive them to give insane level of colors.
Indians can find these at this link
you will also need this app to control it with bluetooth

Step 2: What Is RGB Led ?

Normal led emits monochromatic color output which may be red ,green, or blue.To obtain other color we need to combine the color RGB . This result in 7 different color.To produce more than 7 colors, each color channel should be able to change in brightness, not just turned on or off.
A popular control method is PWM, of which the cycle duty range determines the available brightness levels. The more the levels are available, the more colors can be produced. Apart from the popularity in applications like outdoor decoration lighting in cities, stage lighting designs, home decoration lighting and LED display matrix, RGB color mixing technology can also be found recently in LCD backlighting and projectors.
We learn about PWM later in this Instructables.

RGB can be be of two type

Common Cathode or Common Anode
Common Cathode Three led channel has a single Cathode

Common Anode Three led channel has a single Anode

Step 3: Interfacing RGB Led & RGB Led Strips

RGB LED: In case for RGB led the interfacing is very easy we talk about both Common Cathode And Common Anode.

Common Cathode

R to any PWM channel available

G to any PWM channel available

B to any PWM channel availabl

Cathode to Gnd

Common Anode

R to any PWM channel available
G to any PWM channel available

B to any PWM channel availabl

Anode to 5V

RGB Led Strip

In case of strip out need to switch the the the strip on and off with Mosfet or transistor , i used transistor.
I made the driver and it is also given in the schematics.

Step 4: Controlling RGB

To Control The RGB we need to learn how to control a Normal LED Brightness.
The Answer is PWM Pulse Width Modulation.It is digital representing Analog signal by varing the duty cycle of the pulse.

In arduino, we use the analogwrite function to get a PWM wavethe function generates a square wave of specified duty cycle the value of which is defined by the user.

In the graphic below, the green lines represent a regular time period. This duration or period is the inverse of the PWM frequency. In other words, with Arduino's PWM frequency at about 500Hz, the green lines would measure 2 milliseconds each. A call to analogWrite() is on a scale of 0 - 255, such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time)

Step 5: Connection

The Connection the Mode Lamp is Simple
First we connect the rgb led or strip .

RGB LED/RGB STRIP

Red to Pin 3 of Arduino

Blue to Pin 5 of Arduino

Green to Pin 6 of Arduino

Anode to 5V
If Strip
Gnd of driver to gnd of Arduino

HC-05 Connection

Rx to pin 12 of Arduino

Tx to pin 11 of Arduino

vcc to 5v

gnd to gnd

Step 6: Code

#include <SoftwareSerial.h>
#include <Wire.h>//Include libraries: SoftwareSerial & Wire
SoftwareSerial BT(11,12); //Define PIN11 & PIN12 as RX and TX pins
 
//RGB LED Pins
int PIN_RED = 3;
int PIN_GREEN = 5;
int PIN_BLUE = 6;
//RED LED at Pin 13
int RED_LED = 13;
String RGB = ""; //store RGB code from BT
String RGB_Previous = "255.255.255)"; //preserve previous RGB color for LED switch on/off, default White
String ON = "ON"; //Check if ON command is received
String OFF = "OFF"; //Check if OFF command is received
boolean RGB_Completed = false;
 
void setup() {
  Serial.begin(9600); //Arduino serial port baud rate:9600
  BT.begin(9600);//My HC-05 module default baud rate is 9600
  RGB.reserve(30);
 
  pinMode(RED_LED, OUTPUT); 
  //Set pin13 as output for LED, 
  // this LED is on Arduino mini pro, not the RGB LED
}
 
void loop() {
  // put your main code here, to run repeatedly: 
  
  //Read each character from Serial Port(Bluetooth)
  while(BT.available()){
    char ReadChar = (char)BT.read();
 
    // Right parentheses ) indicates complet of the string
    if(ReadChar == ')'){
      RGB_Completed = true;
    }else{
       RGB += ReadChar;
    }
  }
  
  //When a command code is received completely with ')' ending character
  if(RGB_Completed){
   //Print out debug info at Serial output window
      Serial.print("RGB:");
      Serial.print(RGB);
      Serial.print("     PreRGB:");
      Serial.println(RGB_Previous);
      
      if(RGB==ON){
          digitalWrite(13,HIGH);
          RGB = RGB_Previous; //We only receive 'ON', so get previous RGB color back to turn LED on
          Light_RGB_LED();          
 
      }else if(RGB==OFF){
          digitalWrite(13,LOW);
          RGB = "0.0.0)"; //Send OFF string to turn light off
          Light_RGB_LED();
      }else{
          //Turn the color according the color code from Bluetooth Serial Port
          Light_RGB_LED();   
          RGB_Previous = RGB;     
      }
      //Reset RGB String  
 
      RGB = "";
      RGB_Completed = false;
      
    
  } //end if of check if RGB completed
  
} // end of loop
 
void Light_RGB_LED(){
 
  int SP1 = RGB.indexOf('.');
  int SP2 = RGB.indexOf('.', SP1+1);
  int SP3 = RGB.indexOf('.', SP2+1);
  String R = RGB.substring(0, SP1);
  String G = RGB.substring(SP1+1, SP2);
  String B = RGB.substring(SP2+1, SP3);
 
  //Print out debug info at Serial output window
  Serial.print("R=");
  Serial.println( constrain(R.toInt(),0,255));
  Serial.print("G=");
  Serial.println(constrain(G.toInt(),0,255));
  Serial.print("B=");
  Serial.println( constrain(B.toInt(),0,255));
  //Light up the LED with color code
 
//**2014-09-21
//Because these RGB LED are common anode (Common positive)
//So we need to take 255 to minus R,G,B value to get correct RGB color code
  analogWrite(PIN_RED,  (R.toInt()));
  analogWrite(PIN_GREEN, (G.toInt()));
  analogWrite(PIN_BLUE,  (B.toInt()));
 

If you liked this project support me on Facebook my liking my page

https://www.facebook.com/makewithRex/

, you will aslo be able to talk about your doubts trough the page

Automation Contest 2016

Runner Up in the
Automation Contest 2016

Rainbow Contest 2016

Runner Up in the
Rainbow Contest 2016