loading

I see Halloween as something creepy, or something like ... "Magic".

This rainbow lamp can be used as a night lamp or bring it on Halloween party and show some magic to your friends and kids. It is powered by an Arduino and the trick is on the light dependent resistor to turn on/off the light. It also plays random rainbow colors which is controlled in the Arduino Sketch.

Step 1: Materials

  • An Arduino (uno for testing or pro mini to eliminate the wires).
  • Jumper wires (for testing only).
  • A ball shape lamp shade.
  • A common cathode RGB LED.
  • 3 x 330 ohm resistors (or something near this value).
  • A 10K resistor (or greater value).
  • A photoresistor (light dependent resistor).
  • 7.4 lipo battery (or make your own as low as $4).
  • A battery switch (optional).
  • A 1N7004 diode (optional).
  • A 7805 voltage regulator (optional).

Tool you need is basically a solder iron and some adhesive tape or double sided tape.

Step 2: Wiring

For wiring up your Arduino see the wiring schematic above. Here I use Arduino Uno (Sparkfun RedBoard) and a mini breadboard for testing. Then to fit in the ball lamp, I switch to Arduino Pro Mini 5V which has nothing to change in the code/sketch. Changing to Pro Mini also eliminating the jumper wires which will give a bad shadow inside the ball lamp.

Step 3: Soldering

Going Pro, everything is soldered to the board directly. So you need to place your components well forming a compact size to fit on the bottom of the ball lamp. The RGB LED is placed in the middle and slightly higher. There I put a piece of transparent plastic on the LED to diffuse the light, otherwise there will be a red, green and blue rings on the lamp shade surface. In the photo you can see a bunch of electronic parts, which I will explain more on next step.

Step 4: The Drill (Optional)

We should put the LDR outside of the lamp. Here I drill a small hole to let the LDR leads get in the lamp. Remember to put heat shrink tube or electrical tape on one lead to avoid short. You can skip this step because LDR leads are thin enough and can be stick at the bottom of the lamp shade with the LDR sensor facing outside.

Step 5: Voltage Regulator (Optional)

Leaving my solder iron for too long takes away my skill soldering on tiny spaces like Arduino Pro Mini. Somehow I broke the solder pad on "RAW" pin. Then I couldn't plug my 7.4V battery directly on board. I need a 7805 voltage regulator and a 1N7004 diode. With the 7805 flat surface facing us, connect the left lead to Arduino 5V (VCC). Connect the middle lead to Arduino GND and also Battery negative terminal. Connect the Battery positive terminal to diode and then diode to 7805 right lead with the diode arrow (grey band) facing the 7805.

Step 6: Upload the Sketch

/*

* Playing a rainbow color on RGB LED * By Chienline @2016 */

int redPin = 3; int greenPin = 5; int bluePin = 6; int i,j,k, greenStart, blueStart;

int ldr0 = A0; //define a pin for Photo resistor int sensitivity = 5; int treshold = 50; int prevVal; int currVal; bool ledON = 0;

void setup(){ pinMode( redPin, OUTPUT ); pinMode( greenPin, OUTPUT ); pinMode( bluePin, OUTPUT ); prevVal = analogRead(ldr0); delay(100); RGB_OFF(); }

void loop(){ checkLDR(); }

void checkLDR() { prevVal = currVal; currVal = analogRead(ldr0); if (currVal+treshold < prevVal){ toggleLED(); } delay(sensitivity * 20); //short delay for faster response to light. }

void toggleLED() { if (ledON == false) { ledON = true; RGB_Rainbow(); } else { ledON = false; RGB_OFF(); } }

void RGB_OFF(){ digitalWrite(redPin,LOW); digitalWrite(greenPin,LOW); digitalWrite(bluePin,LOW); }

void RGB_Rainbow(){ int INCi = 1; int INCj = 1; int INCk = 1;

i = random(255); j = random(255); k = random(255); while (ledON){ analogWrite(redPin,i); analogWrite(greenPin,j); analogWrite(bluePin,k); if (i==0||i==255){INCi *= -1;} if (j==0||j==255){INCj *= -1;} if (k==0||k==255){INCk *= -1;} i += INCi; j += INCj; k += INCk; delay(20); checkLDR(); } }

Step 7: Let the Show Begin

Now you can put it in your room as a night lamp or bring it on Halloween to show your magic to the kids.

"Let there be light ... so I can see your future ... "

I put a flashlight near the LDR, so when my hand moves and block the LDR from the light, it will toggle the LED on or off. When I use it as a night lamp in my room, it will start turning on when I turn off the light in the room.

When you use it in Halloween Party, play your hands over and around the ball and it will light up when your hand moving near the LDR and block some light goes to it.

oh I forgot the code... give me an hour to edit. I'm on my way :D

About This Instructable

2,314views

32favorites

License:

Bio: Just an ordinary person who loves #thinking and #tinkering
More by chienline:Box of Connectivity V2.0 Ring Toss Game (From a Box) Fidget Switch : the Power Is in Your Hands 
Add instructable to: