Close
0%
0%

Smart Mood Lamp

A simple project that allows you to make a mood lamp out of an RGB LED and AmebaD RTL8722DM_MINI

Public Chat
Similar projects worth following
0 followers
A simple project that use only a RGB LED and AmebaD RTL8722DM_MINI to make a mood lamp. What is special about this mood lamp, when the surrounding is bright or when the room light is on, it wont turn on. Only when it is dark and room light is off, the mood lamp will turn on and start changing color every few seconds.

Ameba RTL8722DM is a low-power dual-band WLAN and Bluetooth Low Energy SoC by Realtek. The RTL8722DM also include memory for Wi-Fi protocol functions and application making it simple for anyone to develop various kind of IoT applications. At the same time it has a wide range of peripheral interfaces. With all these interfaces, it can connect to most of the electronics components like LEDs, temperature and humidity sensors, and so on.

More Resources:

If you need additional technical documents or the source code for this project. Please visit the official websites and join the Facebook group and forum.

  • 1 × RTL8722DM_MINI Microcontroller
  • 1 × RGB LED Fiber Optics / Emitters
  • 1 × Light Dependent Resistor

View project log

  • 1
    programming
    float RGB[3];
    int ldrPin = 4;     // LDR in Analog Input 0 to read the ambient light
    int ambientLight;   // variable to store the value of the ambient light
    int redLed   = 9;  // red LED in Digital Pin 11 (PWM)
    int greenLed = 5;  // green LED in Digital Pin 10 (PWM)
    int blueLed  = 7;   // blue LED in Digital Pin 9 (PWM)
    
    void setup(){
      pinMode(redLed,OUTPUT);  // tell arduino it's an output
      pinMode(greenLed,OUTPUT);// tell arduino it's an output
      pinMode(blueLed,OUTPUT); // tell arduino it's an output
    
      // set all the outputs to low
      digitalWrite(redLed,LOW);
      digitalWrite(greenLed,LOW);
      digitalWrite(blueLed,LOW);
    }
    
    void loop(){
      for (float x=0;x<PI;x=x+0.00001){
        RGB[0]=255*abs(sin(x*(180/PI)));           // calculate the brightness for the red led
        RGB[1]=255*abs(sin((x+PI/3)*(180/PI)));    // calculate the brightness for the green led
        RGB[2]=255*abs(sin((x+(2*PI)/3)*(180/PI)));// calculate the brightness for the blue led
        ambientLight=analogRead(ldrPin); // read an store the ambient light
        if(ambientLight<600){ // start only if the ambient light is very low
          //  write the brightness on the leds
          analogWrite(redLed,RGB[0]);
          analogWrite(greenLed,RGB[1]);
          analogWrite(blueLed,RGB[2]);
        }
        else{
          digitalWrite(redLed,LOW);
          digitalWrite(greenLed,LOW);
          digitalWrite(blueLed,LOW);
        }
        for(int i=0;i<3;i++){
          if(RGB[i]<1){
            delay(100);
          }
          if(RGB[i]<5){
            delay(50);
          }
          if(RGB[i]<10){
            delay(10);
          }
          if(RGB[i]<100){
            delay(5);
          }
        }
        delay(1);
      }
    }
    

View all 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