Close
0%
0%

Quickly Build Arduino Smart Lamp

Arduino Bluetooth Project

Similar projects worth following

Hi Everyone, Today, we will see how fast we can build the Arduino-based smart lamp, which we can control using a Smartphone. This project required minimal components and was super easy to make. Let's get started.

  • 1 × Arduino UNO
  • 1 × HC-05 or HC-06 Bluetooth Module
  • 1 × RGB SMD LED Module
  • 4 × Some Connector Wires

  • 1
    Circuit Connection

    First, connect the RGB LED module pins starting from Arduino pins 9 to 12, as shown in the video. Then let's connect the HC-05 Bluetooth module VCC pin to Arduino 3.3v pin, GND pin to GND pin, TXD pin to Arduino pin 5 and RXD to Arduino pin 3. We are all done with the circuit connection.

  • 2
    BT Remote Pro App

    Now let's get the BT Remote Pro app which will play a main role in this project. It is a paid app suitable for Arduino and ESP32's Bluetooth-based projects. This app has a joystick, smart light, serial monitor, and voice control features for the Arduino and ESP32's Bluetooth-based projects with example codes. We will use the smart light feature in the BT Remote Pro app for this project.

    BT Remote Pro app link : https://play.google.com/store/apps/details?id=com.locominder.btremote

  • 3
    Arduino Code Upload

    After installing the app, we are all done with the project. Upload the below Smart Light code to Arduino and enjoy the output using BT Remote pro app, as shown in the video. Here is the Arduino code for the Smart Light feature :

    //ARDUINO EXAMPLE CODE
    
    #include <SoftwareSerial.h>
    
    SoftwareSerial BTSerial(5,3); // RX, TX
    
    // PINS ARE DECLARED AS PER ARDUINO UNO BOARD. MODIFY AS PER YOUR BOARD
    int red_pin = 10;
    int green_pin = 11;
    int blue_pin = 9;
    int gnd_pin = 12;
    
    String value = "";
    
    int red;
    int green;
    int blue;
    
    int smooth_brightness = 255;
    int fade_brightness = 255;
    
    int min_brightness_threshold = 50;
    int max_brightness_threshold = 250;
    int brightness_holder = 250;
    
    int fadeAmount = 5;
    int smoothAmount = 1;
    
    
    void setup()
    {
      Serial.begin(9600);
      BTSerial.begin(9600);
      pinMode(gnd_pin, OUTPUT);
      digitalWrite(gnd_pin, LOW);
    
      set_RGB_light(0,0,0);
    
    }
    
    void loop()
    {
     if(BTSerial.available())
     {
       value = BTSerial.readStringUntil('\n');
       Serial.println(value);
       if(value == "BI") // LIGHT BRIGHTNESS INCREASE
       {
    
          if(brightness_holder < max_brightness_threshold)
          {
            brightness_holder = brightness_holder + 50;
    
            set_RGB_light_temp(map(red, 0, 255, 0, brightness_holder),
            map(green, 0, 255, 0, brightness_holder),
            map(blue, 0, 255, 0, brightness_holder));
          }
    
       }else if(value == "BD") // LIGHT BRIGHTNESS DECREASE
        {
    
         if(brightness_holder > min_brightness_threshold)
         {
            brightness_holder = brightness_holder - 50;
    
            set_RGB_light_temp(map(red, 0, 255, 0, brightness_holder),
            map(green, 0, 255, 0, brightness_holder),
            map(blue, 0, 255, 0, brightness_holder));
         }
    
        }else if(value == "P_OFF")  // LIGHT POWER OFF
        {
    
          set_RGB_light(0,0,0);
    
        }else if(value == "P_ON")  // LIGHT POWER ON
        {
    
          set_RGB_light(255,255,255);
    
        }else if(value.indexOf(".") > 0)          // ELSE FOR CHANGE THE LIGHT COLOR
        {
           //GET THE VALUE OF EACH COLOR AND SET TO RGB LIGHT
          set_RGB_light(value.substring(0, 3).toInt(),value.substring(4, 7).toInt(),value.substring(8, 11).toInt());
    
        }
     }
    
      //EFFECTS CODE
       if(value == "FLASH") // LIGHT FLASH EFFECT
        {
    
          set_RGB_light(red,green,blue);
          delay(200);
          set_RGB_light_temp (0, 0, 0);
          delay(200);
    
        }else if(value == "STROBE") // LIGHT STROBE EFFECT
        {
          //SIMPLE STROBE EFFECT
          set_RGB_light(red,green,blue);
          delay(10);
          set_RGB_light_temp (0, 0, 0);
          delay(190);
    
        }else if(value == "FADE") // LIGHT FADE EFFECT
        {
    
           for(fade_brightness = 255; fade_brightness > 0;fade_brightness = fade_brightness - fadeAmount)
           {
            set_RGB_light_temp(map(red, 0, 255, 0, fade_brightness),
            map(green, 0, 255, 0, fade_brightness),
            map(blue, 0, 255, 0, fade_brightness));
            delay(30);
           }
    
    
           for(fade_brightness = 0; fade_brightness < 255;fade_brightness = fade_brightness + fadeAmount)
           {
            set_RGB_light_temp(map(red, 0, 255, 0, fade_brightness),
            map(green, 0, 255, 0, fade_brightness),
            map(blue, 0, 255, 0, fade_brightness));
            delay(15);
           }
    
    
        }else if(value == "SMOOTH") // LIGHT SMOOTH EFFECT
        {
    
           for(smooth_brightness = 255; smooth_brightness > 0;smooth_brightness = smooth_brightness - smoothAmount)
           {
            set_RGB_light_temp(map(red, 0, 255, 0, smooth_brightness),
            map(green, 0, 255, 0, smooth_brightness),
            map(blue, 0, 255, 0, smooth_brightness));
            delay(10);
           }
    
    
           for(smooth_brightness = 0; smooth_brightness < 255;smooth_brightness = smooth_brightness + smoothAmount)
           {
            set_RGB_light_temp(map(red, 0, 255, 0, smooth_brightness),
            map(green, 0, 255, 0, smooth_brightness),
            map(blue, 0, 255, 0, smooth_brightness));
            delay(10);
           }
    
        }
    
    }
    
    
    void set_RGB_light (int R, int G, int B)
    {
        red = R;
        green = G;
        blue = B;
        analogWrite(red_pin, red);
        analogWrite(green_pin, green);
        analogWrite(blue_pin, blue);
    
        // RESET VALUES
        brightness_holder = 250;
    
    }
    
    
    void set_RGB_light_temp (int R, int G, int B)
    {
        analogWrite(red_pin, R);
        analogWrite(green_pin, G);
        analogWrite(blue_pin, B);
    
        // RESET VALUES
        if(value != "BD" && value != "BI")
        {
            brightness_holder = 250;
        }
    }

View all 4 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates