RGB Flashlight
RGB Flashlight
RGB Flashlight
This flashlight can produce hundreds of different colors based on the rotation of a potentiometer. It uses one three watt RGB led to create bright colors.

Parts list:
1x Arduino UNO
1x Atmega328 with arduino bootloader
If you need help buring the boot loader chech out this site http://arduino.cc/en/Tutorial/ArduinoToBreadboard
1x 16 Mhz crystal
2x 19-22 picofarad capacitors
1x 28 pin dip socket
1x 3 watt RGB LED
3x b337 npn transistor
1x lm7805 5 volt regulator
3x 470 ohm 1/8th watt resistor
4x 10 ohm 1/2 watt resistor
2x 22 ohm 1/2 watt resistor
1x Flashlight case, I used a flashlight that took d-cell batteries.
1x Toggel switch, Unless you want to use the switch that is built into the case
1x 9 volt battery
1x 9 volt battery clip
1x 3x3 perfboard
1x 5k ohm potentiomotor
Extra wire
Hot-glue
Solder

Tools:
Soldering iron
Hot-glue gun
Wire cutter
Wire stripper

Step 1: The RGB Sketch

RGB Flashlight
RGB Flashlight
This step explains how the arduino program works, you can skip to the next page if you want.

Basically the code allows you to control the RGB led's Color with one variable instead of three.
Most of the code is dedicated to following the graph I included,it shows what color is generated by mixing different amounts red, green, and blue light.

Program steps:
1. Read the potentiometer's value
2. Convert the potentiometer's value to a more usable number range
3. Using if statements generate the red, green, and blue analog values for each color.

You can copy and paste the code or download the included zip file.
int rpin = 6;//can be any PWM pin int bpin = 3;//can be any PWM pin int gpin = 5;//can be any PWM pin int rcolor = 255;// holds the coresponding brightness for each color int gcolor = 255; int bcolor = 255; int start = 100;// used for the option startup code int potv = 0;// Potentiometer voltage int color =0;//mapped pot value void setup(){ pinMode(rpin, OUTPUT); pinMode(gpin, OUTPUT); pinMode(bpin, OUTPUT); // color check leave this commented out unless you want to // have the flashligth cycle through the colors at the beging // //red // analogWrite(rpin, 0); // analogWrite(gpin, 255); // analogWrite(bpin, 255); // delay(start); // //yellow // analogWrite(rpin, 0); // analogWrite(gpin, 0); // analogWrite(bpin, 255); // delay(start); // //green // analogWrite(rpin, 255); // analogWrite(gpin, 0); // analogWrite(bpin, 255); // delay(start); // //cyan // analogWrite(rpin, 255); // analogWrite(gpin, 0); // analogWrite(bpin, 0); // delay(start); // //blue // analogWrite(rpin, 255); // analogWrite(gpin, 255); // analogWrite(bpin, 0); // delay(start); // //magenta // analogWrite(rpin, 0); // analogWrite(gpin, 255); // analogWrite(bpin, 0); } void loop(){ potv = analogRead(A0); //read Potentiometer position color=map(potv,0,1023,0,1530);// change input number range if(color>= 0 && color = 255 && color = 510 && color = 765 && color = 1020 && color = 1275 && color
RGB Flashlight
rgb.zip956 bytes

Step 2: Uploading The Program

RGB Flashlight
Grab your atmega328 with bootloader and insert it into your Arduino Uno.

First to make sure you atmega328 is working upload the blink sketch from the examples menu in the Arduino IDE. After you have confirmed that you chip works upload the RGB sketch and remove the atmega328 from the Arduino Uno for later use.

Note: I originally configured my Flashlight's atmega328 run on its internal clock, while this eventually did work it was no easy task.
RGB Flashlight
rgb.zip956 bytes

Step 3: Modify The Flashlight Case

RGB Flashlight
RGB Flashlight
RGB Flashlight
RGB Flashlight
First you have to decide if you are going to use the original switch or replace it with your own toggle switch. I replaced my switch because I didn't want to try to solder to the old switch.

After that you can drill a hole for your potentiometer and maybe a switch. Make sure to test fit all your parts.

Next you need to replace the original light bulb with your high power led. Each flashlight will be different but for mine I removed what the old light bulb screwed into and used hot glue to attach the new led.

Finally take your perfboard and cut it so that it will fit in the flashlight tube I like to use wire cutters for this step.

Step 4: Place Componets

RGB Flashlight
RGB Flashlight
RGB Flashlight
I drew the schematic in a rather unconventional way so if you have any questions please ask and I will try to answer them. The numbers by the resistors are their values in ohms and the 22 ohm resistor pair is for the led's red channel.

I highly recommend that you actually have a plan before you start to solder parts to your perfboard. I did not and I had trouble fitting the parts into the flashlight at first. I recommend that you put all of your parts in the board and tape them down. Then plan as much of your soldering out as is possible by using a permanent marker to draw paths.


Step 5: Solder

RGB Flashlight
RGB Flashlight
Now its time to solder, hopefully your board will be a little bit more organized then mine but if it works who cares.

To go longer distances across the perfboard I like to use pieces of wire and bent leads. After you solder cut any extra leads and insert your programmed atmega328 into its socket.

Make sure to double check your circuit to prevent damage to the circuit.
If all looks well power up your circuit to test it.


Step 6: Install

RGB Flashlight
Fitting every thing in can be tricky at first. I started by attaching my switch and potentiometer. Then I dropped the 9 volt battery in and slipped in the perfboard. If it doesn't fit you can try bending some parts down, but you might need to get your soldering iron back out and move some things. Finally screw on the lid.



Step 7: Color With Light

RGB Flashlight
RGB Flashlight
RGB Flashlight
RGB Flashlight
Now that you have your flashlight built turn it on and have some fun with it.
 
 

Tag cloud

make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel