timstephens

LED Night Light

I created a bright night-light by repurposing an old colander to form the shade, and fitting colour-changing LEDs inside. The LEDs are a strip of 16 individual lamps, each controlled by a WS8215 chip, which is an addressable RGB LED controller. This means that each LED can be individually controlled. I used an Arduino Nano board that I had knocking around to run the LEDs, with Adafruit’s Neopixel library.

 Hardware

The lamp is powered by a wall-wart power adaptor from an old router that produces 12v. The LEDs require up to 1A at 5v (depending on whether they’re displaying pure white or not), so I use a simple 78L05 regulator. As you might imagine, this gets quite hot because of the amount of power that it has to dissipate. The ideal solution would be to find a 9v or 7.5v power supply so that less power is being dissipated in the regulator.

The Arduino and the regulator sit on a small piece of Veroboard to hold everything together, and are then mounted onto the core of an old roll of sellotape in the centre of the lamp-shade. Ultimately, there will be a metal core for the LEDs to provide better heatsinking, but I need to buy and consume a suitable diameter tin of food for this to happen (I think that a tin of Tuna will probably do it).

The shade is an old colander that fell apart and was no longer useful. I cut a disc of wood using my router to closely match the outer diameter of the colander, and added a lip at a smaller diameter that matches the inside diameter. This means that the colander locates on the lip, which keeps it centred on the base. In the first iteration, Duct tape is used to clean up the joint, but child-proofing will probably mean that I add some beading to tidy things up.

Code

The code is a direct lift from one of the Adafruit example projects, and further fanciness is left as an exercise for the reader.

#include <Adafruit_NeoPixel.h>
#include <avr/power.h>

#define PIN            7
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      16


Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 500; // delay for half a second
int lightMode = 0;

void setup() {

  strip.begin(); // This initializes the NeoPixel library.
}

void loop() {
    rainbowCycle(20);
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for (j = 0; j < 256 ; 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);
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if (WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else if (WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  } else {
    WheelPos -= 170;
    return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  }
}