Project showcase
Wireless LED Lamp with IR Remote Control

Wireless LED Lamp with IR Remote Control © GPL3+

An Arduino controlled glowing orb LED lamp with IR remote control.

  • 40 views
  • 0 comments
  • 1 respect

Components and supplies

Apps and online services

About this project

This is version 2 of my previous LED lamp, now with an Arduino controlled RGB LED and IR remote control.

Basic Construction

Fitting an Arduino Nano inside the snow globe turned into a messy, and not particularly good looking, job as it had to be mounted upside down inside the plug so that glare from the red indicator lights didn't interfere as much with RGB glow.

Once the Arduino was secured in place I added the RGB LED and IR receiver module.

Wireless Power

The Arduino is powered using a wireless charger kit, with one coil mounted inside the lamp and the other in a simple 3D printed box (printed by Mortar Art). A note about this kit: The coils only provide full power when they're both the correct way up, so remember to double check this before final assembly.

IR Remote Control

The IR kit comes with a remote, a receiver module and a spare IR emitter. By using the Serial.println() function to discover the resulting codes for each button I was then able to map them to various functions within the Arduino program.

The lamp has 2 modes:

  • Solid colour on at full brightness (red, green, or blue)
  • Colour fade (heavily adapted the fade example code provided with the Arduino IDE )

Problems and Possible Solutions

  • The Arduino Nano's indicator lights (power and activity) are too bright and can't be disabled in the software. If I use this board for other lighting projects I'll encase the board entirely to prevent further light leakage.
  • The snow globe's plastic plug loses all structural integrity if you make too many holes in it. This plug could be custom designed and 3D printed, probably in black ABS to help with the light leakage problem.
  • The single RGB LED isn't diffused enough inside the sanded snow globe. An array of LEDs might work better here.

Code

Code For IR Remote Control Of LampArduino
#include <IRremote.h>

int RECV_PIN = 12;
int ledPins[] = {5, 6, 9};

IRrecv irrecv(RECV_PIN);
decode_results results;

int on = 0;
int mode = 1;
int minmode = 1;
int maxmode = 2;
int ledcolor = 0;
int minledcolor = 0;
int maxledcolor = 2;
unsigned long last = millis();

int brightness = 0;
int fadeAmount = 5;


void setup() {
  int i;
  for (i = 0; i < (sizeof(ledPins)/sizeof(int)); i = i + 1) {
    pinMode(ledPins[i], OUTPUT);
  }

  irrecv.enableIRIn();
}

void led_active_control(int led) {
  leds_off();
  digitalWrite(ledPins[led], HIGH);
}

void leds_off() {
  int i;
  for (i = 0; i < (sizeof(ledPins)/sizeof(int)); i = i + 1) {
    digitalWrite(ledPins[i], LOW);
  }
}


void loop() {
  if (irrecv.decode(&results)) {
 
    if (millis() - last > 250) {
      Serial.println(results.value, HEX);
      if(results.value == 0xFF38C7 || results.value == 0x58A310EF) {
        on = !on;
      }
      
      if(results.value == 0xFF10EF) {
        if(ledcolor > minledcolor) { 
          ledcolor -= 1;
        }
      }
      
      if(results.value == 0xFF5AA5) {
        if(ledcolor < maxledcolor) { 
          ledcolor += 1;
        }
      }

      if(results.value == 0xFF4AB5) {
        if(mode > minmode) { 
          mode -= 1;
        }
      }

      if(results.value == 0xFF18E7) {
        if(mode < maxmode) { 
          mode += 1;
        }
      }
    }
    last = millis();
    irrecv.resume();
  }
  
  if(on) {
      if(mode == 1) {
        led_active_control(ledcolor);
      } else if(mode == 2) {
        leds_off();
        
        analogWrite(ledPins[ledcolor], brightness);

        brightness = brightness + fadeAmount;

        if (brightness <= 0 || brightness >= 255) {
          fadeAmount = -fadeAmount;
        }
        delay(30);
      }
      
    } else {
      leds_off();
    }
}

Custom parts and enclosures

Lamp Base STL
Lamp Base on Thingiverse

Comments

Similar projects you might like

Control an LED with the Remote Control

Project showcase by Nicholas_N

  • 2,814 views
  • 1 comment
  • 7 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,176 views
  • 5 comments
  • 15 respects

IR Remote Control for Presentation PC

Project showcase by PiotrSylwesiuk

  • 1,378 views
  • 1 comment
  • 5 respects

Remote Lamp

Project tutorial by Kutluhan Aktar

  • 1,786 views
  • 0 comments
  • 7 respects
Add projectSign up / Login