Introduction: Bluetooth Smartphone-controlled Smart LED Lamp

About: I believe that developing something creative will help in my study.

I always dream of controlling my lighting appliances. Then someone made an incredible colourful LED lamp. I recently came across an LED Lamp by Joseph Casha on Youtube. Getting inspired by it, I decided to add several functions while keeping the contemporary design.

The plan is to make the lamp to be more user-friendly by adding a Bluetooth Module and addressable WS2812B RGB LED strip. This made it possible to control the colour of the lighting just by using a smartphone app.

Step 1: Gather the Materials

Tools:

• Soldering Station

• Heater Blower Gun

• Drill Machine

• Circular Saw

• Jigsaw

• Wire Cutter Pliers

• Narrow-nose Pliers

Materials:

• Translucent Acrylic Board

• Japanese Cypress Wood ( or you can use any wood as long it is stable and strong enough )

• Screws

• Stainless Steel Pole or Stick

• Wires ( I use red and black wire )

• Soldering Tin

Electronics Components:

• Arduino Nano

• Bluetooth Module HC-05 ( I decided to use this as it is easier to code than Wifi Module ESP8266 )

• WS2812B Addressable RGB LED Strip

• LM2596 Step-down Module

• DC Barrel Power Jack

Step 2: Building the Structure of the Lamp

In this step, I have two ways of building the structure of the lamp- woodworking method and 3D-printing method. I use the first method. If you prefer to make it by using a 3D printer, feel free to skip to step 2 for the model that I designed.

For the upper part of the lamp, I heat and bend the acrylic board to a 90° angle as shown above. I take quite a long time to bend it to such a perfect angle and direction.

Next, for the lower part of the lamp. Unfortunately... the day that I'm working on the lower part of the lamp, I completely forgot to take a picture of the construction! I realized that when I finished this project. But I'll try my best to provide you with the measurement of the lower part of the lamp.

Basically, you just need to cut four blocks of wood that measure 13x6x2cm ( LxHxW ). Next, you need to cut a stair-like cut at the edge of the wood. The picture will be shown above.

Step 3: The 3D Shapes

For anyone who has their own 3D printer, you are in the right step. This made this lamp user-friendly.

To be honest, this was the hardest step that I did. This is the first thing I did right after installing the software!

I use Sketchup Pro to design the structure of the lamp. Unfortunately, I'm not skilful enough to design its interior component. The link to my 3D model is in the file below.

Step 4: The Components' Schematic

I use Fritzing to construct the schematics of the components. The schematic is actually pretty easy.

Step 5: The Code

For the coding of this mood lamp, I used some libraries from the Arduino IDE. The libraries will be listed down on step 7.

For the code, you need to have the Arduino software itself. I will provide the link to download here.

Also, the sketch or the code will be shown below 👇

I also provided the file for the code in Github.com in case the code below is too long to copy here ;)

<p>#include <FastLED.h><br>#include <SoftwareSerial.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include 
#endif</p><p>SoftwareSerial BT(10, 11);  
#define LED_PIN      7   
#define NUM_LEDS    60   
#define BRIGHTNESS   200   
#define SPEED          10    
#define IMMEDIATELY    0    
#define RAINBOW_SPEED  50   
CRGB leds[NUM_LEDS]; </p><p>Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);</p><p>bool offOld = LOW;
bool WhiteOld = LOW;
bool RedOld = LOW;
bool GreenOld = LOW;
bool BlueOld = LOW;
bool TopazOld = LOW;
bool LilacOld = LOW;
bool RainbowOld = LOW;
bool rgbOld = LOW;
int  showType = 0;</p><p>void setup() {</p><p>FastLED.addLeds(leds, NUM_LEDS); //////////
  
   </p><p>   BT.begin(9600);
   
   BT.println("Connected to Arduino");
    </p><p>  strip.setBrightness(BRIGHTNESS);  
   </p><p>  strip.begin();
  strip.show();</p><p> 
}</p><p>char a;</p><p>void loop() {
 for (int i = 0; i <= 59; i++) {
       leds[i] = CRGB(255, 255, 255);
       FastLED.show();
   }
  
  bool off = LOW;
  bool White = LOW;
  bool Blue = LOW;
  bool Red = LOW;
  bool Green = LOW;
  bool Topaz = LOW;
  bool Lilac = LOW;
  bool Rainbow = LOW;
  bool rgb = LOW;
  bool ende;
  
   if (BT.available())
   {
    a= (char)BT.read();</p><p>    if(a=='o')
    {
      off = HIGH;
          BT.println("TURNING OFF LEDs..");</p><p>    }else{
          off = LOW;
    }
    
// ===========================================================================================</p><p>    if(a=='w')
    {
      White = HIGH;
          BT.println("TURNING LEDs WHITE");</p><p>    }else{
          White = LOW;
    }
    
// ===========================================================================================</p><p>    if(a=='b')
    {
      Blue = HIGH;
          BT.println("CHANGING TO BLUE");      
          
    }else{
          Blue = LOW;  
    }</p><p>// ===========================================================================================</p><p>if(a=='r')
    {
      Red = HIGH;
          BT.println("CHANGING TO RED");            
    }else{
          Red = LOW;  
    }</p><p>// ===========================================================================================</p><p>if(a=='g')
    {
      Green = HIGH;
          BT.println("CHANGING TO GREEN");      
          
    }else{
          Green = LOW;
    }</p><p>// ===========================================================================================</p><p>if(a=='t')
    {
      Topaz = HIGH;
          BT.println("CHANGING TO TOPAZ");      
          
    }else{
          Topaz = LOW;
    }</p><p>// ===========================================================================================</p><p>if(a=='l')
    {
      Lilac = HIGH;
          BT.println("CHANGING TO LILAC");      
          
    }else{
          Lilac = LOW;
    }</p><p>// ===========================================================================================</p><p>    if(a=='a')
    {
      Rainbow = HIGH;
          BT.println("RAINBOW ANIMATION");      
          
    }else{
          Rainbow = LOW;  
    }
    
// ===========================================================================================</p><p>     if(a=='m')
    {
      rgb = HIGH;
          BT.println("MIX COLORS");      
          
    }else{
          rgb = LOW;  
    }
}
if (off == LOW && offOld == HIGH) {
    delay(20);
   
    
    if (off == LOW) {
       showType = 0  ;                            // Off animation Type 0
     
      startShow(showType);
    }
  }</p><p>// ===========================================================================================</p><p>if (White == LOW && WhiteOld == HIGH) {
    delay(20);
   
    
    if (White == LOW) {
       showType = 1  ;                            // White animation Type 1
     
      startShow(showType);
    }
  }</p><p>  
// ===========================================================================================  
  
  if (Red == LOW && RedOld == HIGH) {
    delay(20);
   
    
    if (Red == LOW) {
       showType = 2  ;                            // Red animation Type 2
     
      startShow(showType);
    }
  }</p><p>// ===========================================================================================</p><p>if (Green == LOW && GreenOld == HIGH) {
    delay(20);
   
    
    if (Green == LOW) {
       showType = 3  ;                            // Green animation Type 3
     
      startShow(showType);
    }
  }
  
// ===========================================================================================</p><p>if (Blue == LOW && BlueOld == HIGH) {
    delay(20);
   
    
    if (Blue == LOW) {
       showType = 4  ;                            // Blue animation Type 4
     
      startShow(showType);
    }
  }</p><p>// ===========================================================================================</p><p>if (Topaz == LOW && TopazOld == HIGH) {
    delay(20);
   
    
    if (Topaz == LOW) {
       showType = 5  ;                            // Topaz animation Type 5
     
      startShow(showType);
    }
  }</p><p>// ===========================================================================================</p><p>if (Lilac == LOW && LilacOld == HIGH) {
    delay(20);
   
    
    if (Lilac == LOW) {
       showType = 6  ;                            // Topaz animation Type 6
     
      startShow(showType);
    }
  }
    
// ===========================================================================================</p><p>    if (Rainbow == LOW && RainbowOld == HIGH) {
    delay(20);</p><p>    if (Rainbow == LOW) {
showType = 8;                            // Rainbow animation Type 8
      startShow(showType);
    }
  }</p><p>// ===========================================================================================</p><p>      if (rgb == LOW && rgbOld == HIGH) {
    delay(20);</p><p>    if (rgb == LOW) {
   showType = 7;                            // Mix animation Type 7
     rgb = HIGH;</p><p>      startShow(showType);
    }
  }</p><p>WhiteOld = White;
RedOld = Red;
BlueOld = Blue;
GreenOld = Green;
TopazOld = Topaz;
LilacOld = Lilac;
offOld = off;
RainbowOld = Rainbow;
rgbOld = rgb;</p><p>}</p><p>void startShow(int i) {
  switch(i){</p><p>    case 0: colorWipe(strip.Color(0, 0, 0), SPEED);    // Black/off
            break;</p><p>    case 1: strip.setBrightness(255);                            // Changes the Brightness to MAX
            colorWipe(strip.Color(255, 255, 255), IMMEDIATELY);  // White
            strip.setBrightness(BRIGHTNESS);                     // Reset the Brightness to Default value
            break;  </p><p>    case 2: colorWipe(strip.Color(255, 0, 0), SPEED);  // Red
            break;</p><p>    case 3: colorWipe(strip.Color(0, 255, 0), SPEED);  // Green
            break;</p><p>    case 4: colorWipe(strip.Color(0, 0, 255), SPEED);  // Blue
            break;</p><p>    case 5: colorWipe(strip.Color(0, 250, 255), SPEED);  // Topaz
            break;            </p><p>    case 6: colorWipe(strip.Color(221, 130, 255), SPEED);  // Lilac
            break;            
    
    case 7: colorWipe(strip.Color(255, 0, 0), SPEED);  // Red
            colorWipe(strip.Color(0, 255, 0), SPEED);  // Green
            colorWipe(strip.Color(0, 0, 255), SPEED);  // Blue
            theaterChase(strip.Color(  0,   0, 127), SPEED); // Blue
            theaterChase(strip.Color(127,   0,   0), SPEED); // Red
            theaterChase(strip.Color(0,   127,   0), SPEED); // Green
            break;</p><p>    case 8: rainbowCycle(25);
            break;
            
  }
}
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i</p><p>void rainbowCycle(uint8_t wait) {
  uint16_t i, j;</p><p>  for(j=0; j<256*10; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}</p><p>void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();</p><p>      delay(wait);</p><p>      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}</p><p>uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}</p>

Step 6: Controlling the Lamp

Colour of the lamp can be controlled by using your smartphone.

First, you need to install the app called 'Bluetooth Terminal HC-05' from Google Play Store or Apple App Store.

These are the steps to control the lamp via your own smartphone:

1. Turn on bluetooth in your smartphone.

2. Open the app which is 'Bluetooth Terminal HC-05'.

3. You should now see the paired devices on the screen. Choose 'HC-05'.

4. Now you can see a black screen appears in your smartphone that will indicate 'connected to Arduino'.

5. Here is the fun part, if you type 'b' in the textbox, the lamp will turn to blue colour. Here is the list of the command that you can type for the lamp:

- w for white

- b for blue

- g for green

- r for red

- t for topaz

- l for lilac

- a for rainbow animation

- o for off

Fun right?

6. Last but not least, you also can customize the button below the screen to your desired text as shown in the picture above.

Step 7: Enjoy Your Mood Lamp!!

I hope you like this Instructables. It was a very challenging project for me but I managed to finish it completely as a 14 years-old boy. Do give me some feedback for future improvements.

Thanks for reading and Merry Christmas!

Make it Glow Contest

Participated in the
Make it Glow Contest