Introduction: SmartPhone Controlled RGB MOOD Light

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

Comments

author
pawtanwar (author)2017-05-12

wouldn't you require a a voltage divider between the tx ouput on the Uno and the HC 05 to drop the voltage to 3.3 volts??

author
MISHA the same (author)2017-03-06

Good job. Thanks I was make yeelight

author
Gursimran Singh 425 (author)2016-07-08

Congratulations Prajjwal, this was plain awesome, I like your tutorials about home automation. Congratulations twice!! :-D

author

Thank Gursiman ,Congrats to you also .
your CNC is cool I am making one CNC some time Sooner.

author
destone28 (author)2016-07-05

Well explained and nice Instructable! Good luck for the contests! ;-)

author
geekrex (author)destone282016-07-08

Thank you

author
mghary (author)2016-07-02

hello

I from iran

I didnt study rdurino

I want learn adurino

I study Electrical engineer

how can learn me?

tanks u

mghary

author
pasaal (author)2016-06-21

Can you make and give me i live in india

author
geekrex (author)pasaal2016-06-21

where do you stay

author
kitefaster (author)2016-05-31

Check out this instructable that uses an iOS app for iPhone or iPad:

https://www.instructables.com/id/Control-a-LED-light-strips-color-via-an-Arduino-an/

author
geekrex (author)kitefaster2016-06-10

great

author
loskop100. (author)2016-06-01

Good job but you will need to insert a voltage divider between the tx ouput on the Uno and the HC 05 to drop the voltage to 3.3 volts or it will stop working after a while.

author
geekrex (author)loskop100.2016-06-10

there is a interface board so no worry

author
Raphango (author)2016-06-01

Nice! =D

author
geekrex (author)Raphango2016-06-10

thanks

author
pasaal (author)2016-06-10

can you give list of everything needed and websites if available

author
geekrex (author)pasaal2016-06-10

given in step 2

author
efbe1840 (author)hemaraj2016-06-03

This seems to be the original, and works with common anode LEDs

author
geekrex (author)hemaraj2016-05-24

great i saw u made a led strip but u should have made it parallel or is it in series ??

author
hemaraj (author)geekrex2016-05-25

i made the strip in parallel but i connected it in series

author
geekrex (author)hemaraj2016-05-25

great man , you did a good work

author
donfrench (author)2016-05-31

You should mention that you can not use your iPhone to control this or any other serial Bluetooth device (not talking BLE now). This is because Apple will not allow an iOS app to connect to a serial Bluetooth device without 1) becoming "Made for iPod" certified, a months-long process that costs $20,000 on average; and to qualify you need to pass a credit check that includes giving them your last three years' tax returns! 2) including one of their special encryption chips on your device - that you have to buy from them 3) pay Apple a royalty on every device you sell if you go commercial with your project. All this just to make a product that makes their product more valuable.

author
nufegiyq (author)donfrench2016-05-31

Sorry friend, nothing about this is true. I control my similarly constructed RGB strips with an iPhone app downloaded from the App Store.

author
donfrench (author)nufegiyq2016-05-31

It's not? When did they change that policy? I make a commercial product that they would not support and their official communication with me was exactly what I just reported. In fact I went as far as applying for Made For iPod certification but balked when they demanded I supply my tax returns. But that was three years ago so maybe they changed their policies since then. Which app did you download?

author
donfrench (author)donfrench2016-05-31

As late as December 2015, Apple did NOT support classic serial bluetooth (SPP, to be technical). You might want to read this thread on the official Apple discussion site: https://discussions.apple.com/thread/7400388?start=0&tstart=0 .I don't think this has changed since last December but if you know differently, please let us know where you got that information. As I said in my comment, BLE is a different matter but this is not BLE.

author
donfrench (author)donfrench2016-05-31

As late as December 2015, Apple did NOT support classic serial bluetooth (SPP, to be technical). You might want to read this thread on the official Apple discussion site: https://discussions.apple.com/thread/7400388?start=0&tstart=0 .I don't think this has changed since last December but if you know differently, please let us know where you got that information. As I said in my comment, BLE is a different matter but this is not BLE.

author
YaddyVirus (author)2016-05-31

Hey there! Nice tutorial, however I am more interested in how you made the app, as I would like to make that for my windows phone.

author
kitefaster (author)2016-05-31

Check out this instructable that uses an iOS app for iPhone or iPad:

https://www.instructables.com/id/Control-a-LED-light-strips-color-via-an-Arduino-an/

author
Jonathanrjpereira (author)2016-05-31

Link to the app??

author
MikkelN (author)2016-05-31

Simple and good looking, well done! :)

author
MikkelN (author)2016-05-31

Simple and good looking, well done! :)

author
OmarO15 (author)2016-05-26

Very nice.

author
AXR AMAR (author)2016-05-26

nice bro !!

author
geekrex (author)AXR AMAR2016-05-26

thanks

author
meghla.banik (author)2016-05-24

Great :D

author
geekrex (author)meghla.banik2016-05-24

thanks

author
KNEXnCoding (author)2016-05-23

Very cool!

author
geekrex (author)KNEXnCoding2016-05-24

thanks man

About This Instructable

26,275views

390favorites

License:

Bio: 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 ... More »
More by geekrex:DIY 3D Printed Desk Lamp$200 DIY 3D Printer Build$1 DIY Fidget Toy
Add instructable to: