Introduction: Ambient Batman Lamp - Arduino |Photo-Resistive| Auto-On When Dark | MultiColor
Hello everybody! This is my first instructables and any suggestions would be greatly appreciated. There are many versions of the batman lamp and I thought to showcase my version. This lamp is light dependent, i.e. it detects light using a photo-resistor (sometimes referred to as Light Dependent Resistor) and when the light level goes down beyond a certain level, it automatically switches on the LED lights.
This lamp might look a bit hard to make but actually, it is quite simple. The batman logo is made up of cardboard and since it uses cardboard from old boxes, its Eco-Friendly! You may swap the LEDs with RGB led with the help of which you can produce any color, making it a rainbow batman lamp. I will be providing the code for the same. The lamp beautifies the wall on which it is hung, especially if the color shade of the wall is light.
The lamp uses PWM pins of arduino to produce fading effects.
The lamp in action, here's the link: http://www.youtube.com/watch?v=nMVVGQpGB8I
So lets start the project and if you have any doubt or found any error or have suggestions, feel free to comment. And one last thing before starting, Please vote for me in all the contest by clicking on the orange button named 'Vote' in the top right corner.
Step 1: Materials Required
All the electronic components can be bought online and will cost ~$28-$30 and the materials can be found in your nearest stationery store and hardware shop.
Electronic Parts:
• 1x Photo-Resistor
• 1x Arduino Uno
• 1x 9V Battery and Battery Clip or DC Supply
• 1x 100k Ohms Resistor
• 2x ~100 Ohms Resistor
• 2x RGB Led or Led of your choice
• Breadboard
• Jumper Wires
Materials and Tools:
• A3 Size Sheet [Optional]
• Acrylic Colors
• Paint Brush
• Cardboard
• Tape
• Sand Paper
• Scissors
• Adhesive
Step 2: Sketch the Bat and Cut It Out
Make the bat on the cardboard. Take help of the picture for dimensions. Then you need to cut it out with a paper cutter. You can also print the picture of it and then trace it on cardboard/ wood.
Step 3: Smooth the Edges
Use a sand paper to smooth the edges and get a neat effect. You won't like pieces of cardboard hanging loosely at the sides destroying the beauty of the lamp, right?
Step 4: [Optional] Pasting A3 Sheet
Trace the shape on an A3 size sheet and cut it out. Then paste it on the cardboard to give a smooth look. Painting on the paper will be easier and it will hide the uneven surface of cardboard.
Step 5: Paint It
Take acrylic black paint and a brush and start painting it. If you stick a black sheet, it will reduce the task and there will be no need to paint it.
Step 6: The Wiring
Connect it as done with RGB lights in the middle facing the opposite side of the bat. Colour code of wire-
- Black- Negative
- Orange- 5V to 100k resistor
- Purple- A0 pin to lane having resistor and photo-resistor
- Blue- RGB's blue pin to pin 10
- Green- RGB's green pin to pin 09
- Red- RGB's red pin to pin 11
Step 7: Time to Code
Code 1
The following code was taken from : here
float RGB[3];
int ldrPin = 0; // LDR in Analog Input 0 to read the ambient light
int ambientLight; // variable to store the value of the ambient light
int redLed = 11; // red LED in Digital Pin 11 (PWM)
int greenLed = 9; // green LED in Digital Pin 9 (PWM)
int blueLed = 10; // blue LED in Digital Pin 10 (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
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);
}
}
Code 2:
If you don't like the fading effects and have leds of just one color [for ex only yellow leds] and prefer simple glowing lights use the following code instead:
//Connect leds in parallel and to digital pin11
//Author: Amit Shekhar
//Batman Lamp Light Dependent
float RGB[3];
int ldrPin = 0; // LDR in Analog Input 0 to read the ambient light
int ambientLight; // variable to store the value of the ambient light
int Led = 11; // LED in Digital Pin 11
void setup(){
pinMode(Led,OUTPUT);
digitalWrite(Led,LOW);
}
void loop(){
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
digitalWrite(Led,HIGH);
}
else{
digitalWrite(Led,LOW);
}
}
Step 8: Power the Lamp
Use a 9V battery with a power clip or a DC adapter to power the lamp. I did it using a spare phone charger.
Step 9: Upload the Code
Copy paste the code into Arduino application and hit the upload button. Test whether the connections are secure.
Step 10: Hang It on the Wall
Put two small plastic containers at the back with small holes so that they can be hung on nails.
Step 11: You're Done
Now just sit back and enjoy. I hope you liked this project and if you think that this deserves to win the contest, don't forget to click on the orange button named 'Vote' on the top right corner. And again feel free to ask any doubts, correct any error or suggest something. Cheers!

Participated in the
Before and After Contest

Participated in the
Fandom Contest

Participated in the
Rainbow Contest
3 Comments
8 years ago
Really a great job on your first instructable! A video of the lamp in action would be great.
Reply 8 years ago
Thanks for the suggestion, I had been working with it but the embedded video feature didn't show up in mobile site. So, I guess, I will do with a hyperlink.
Reply 8 years ago
Looking forward :)