I wanted to have an easily programmable RGB light to toss into a Jack 'O Lantern for Halloween. Who really wants a dull pumpkin in these days of pumpkin pimping madness. So I set to work building a pocket tin sized RGB lamp that could be reused after Halloween for some other RGBing need. The goal, that it could fit into a tin with room to spare for possible future additions, that it be hyper-simple to write up a new light show. That it used an Arduino at its heart, because I am familiar with them and they are fun.
So lets get to making something!
If you are here for the library it is in step 3. Go on then, let then others read quietly.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Gather Up Your Kit
To build a replica of my pocket RGB lamp, you will need....
A RGB LED..(You can get these at most electronics stores/sources)
An Arduino Mini Pro 5v (Available from Sparkfun and Robotshop and a bunch of other places too)
A good pocket sized tin that can house a 9v battery and some stuff. I used an alternative to the minty fresh choice of many a maker. Mine, while lacking in freshness is both sharp and precisely engineered...or so I am lead to believe....Your tin will be fine, don't get tin envy...honestly it is only a tin.
A small protoboard, or a larger one that you don't mind cutting to make a smaller piece.
3 resistors, I went with 330ohms. Usually a safe bet with LEDs, but if you have your datasheet, and options, do the math...V=IR is a good place to start.
A 9v battery connector
Some female headers (available at many online retailers)
a small on/off push-button (Dollarama is a great place to find stuff like this attached to other stuff that is also often useful)
Some bits of hookup wire.
some thin foam or thick paper or something to line the bed of the tin in to keep it from shorting out anything.
A small credit card Fresnel magnifier. Not strictly necessary, but I like excuses to cut up credit card sized Fresnel lenses.
ummm...a drill, a computer....ummm...thats it I think.
Okay have you gathered your gear? Do a dry fit. Put the board and battery in the tin, place other components on top, close tin. If the test goes well, proceed to next step, otherwise, figure out what is going to be the problem and then find a slightly larger tin.
I had to cut a bit of my protoboard off. A quick way to do this if you don't mind a rough cut is to score a line and snap it off.
Step 2: Solder Up Your Board
Start by sliding your female headers onto your Arduino mini and positioning the whole thing on your protoboard. This ensures that everything mates nicely at the end, you can just solder the headers in, but if they sit a little off of square, it makes a rougher socket fit.
Make sure you don't have pins overtaking the perimeter of the board, as these could make contact with the tin and short the circuit.
Position your RGB LED as well, somewhere that gives you a little room to work, there is loads of real estate available. I placed mine so it would sit roughly centered in the length of the tin.(see the little pen mark, I scratched that on during my dry fit)
A little piece of electrical tape on each bit helps to hold it in position when we flip it over to solder.
Do that next, solder it up and get rid of the tape, clip your excess leads. Another trick is to stick your lead clippings to your discarded bit of tape, stepping on a lost one hurts.
Next, run one resistor each off of pins 9, 10, and 11. Use some wire and run from the other end of the resistor to the anodes of your RGB LED. You will want pin 9 connecting to the red anode, pin 10 to green and pin 11 to blue if you plan on using the little Moodlamp Library I have included. Again, that's 9 to red with a resistor, 10 to green with a resistor, 11 to blue with a resistor. Solder the cathode out to an empty area on the board. (Don't worry, we'll ground it soon)
Solder an on/off button in a place that you find appealing. Run a wire from ground on the Arduino mini to the cathode of the RGB LED. Then connect the positive of your battery connector to the other button terminal, and the negative to your little grounding zone. (where the cathode from the LED ends)
Snip your leads and inspect your soldering job before applying power.
Step 3: Test Drive (The Library)
Now is a good time! It is though isn't it. A good time? You, me, a thousand others watching......
Sorry, just keeping it interesting.
What I had meant to say was that now would be a good time to upload some code to the Arduino. Besides, that is probably why you are really reading this at all, there are a bunch of RBG lamps out there, many much more dazzling than this one. I don't like to say it, but nothing makes this lamp special. Nothing except that I have included a small library for download, changing, eating, although I don't recommend the latter. It is a simple little library that simplifies the code for a lot of the little effects that people like to do with RGB LEDs.
So before we put it all together in our tin, let's install the library (fun eh) and upload some code.
(UPDATE!! I just added the files in their proper format, apparently you can, I thought you couldn't) So now just put the cpp and h file together in a folder called Moodlamp in your Libraries folder. (In your sketches folder, if it is not there create it) Hope this simplifies things.
Open up the Arduino environment and the library will compile and be made available. If it worked you should be able to see it in your import library menu in the Arduino environment. (Under the sketch heading).
Moodlamp_PDE.txt is the example Arduino sketch, open it, copy paste it into a new sketch in Arduino. Now you can upload the example provided, or open it up and change it around. Like I mentioned, this little library does most of the fun moodlamp stuff and it makes it simple. Basically tell it which color code you want to use and how. It handles smooth fades from colour to colour, or instant switching. Pulsing, spinning, candle flame flickering, random colour generation and all highly customizable to your needs. Giving you complete control without mucking about with a whole slew of code for a silly little light. Usage is detailed in the help.txt file. Pretty staightforward I think, post questions if you have them and I will do my best to help.
I hope some of you are kind enough to post links etc to projects that use the library. Share and enjoy!
If everything has gone well, you should be able to load the example sketch, plug in a battery and watch the magic...erm..well...little light blending and changing colours. Which is cool. Cooler with a nice diffuser...like say a Jack 'O Lantern? So test done, everything works, lets get back to the build and finish this little project up.
Step 4: Finishing the Enclosure
If you don't trust your eyes, you could try a ruler. Or any other method you like, I am assuming you all have one. If you don't you should put it as a top of the list personal goal. "Decide on my personal preferred method of measuring things". You might want to set aside an evening.
Okay make your marks.
Drill your holes. I used a small forstner bit for the larger hole, I went with a size that accommodated my lens.
gently replace the cover to see that it all lines up. Make adjustments if necessary.
Time to insulate the box from shorting anything out. I found a whole big pack of foam sheets at the Dollar store (From some other project). I find them great for all kinds of things, insulating project tins being one of them. I went with a sporty orange. It was Pumpkiny and fast looking, which are both pretty good things.
Use the lid to trace the contour, cut it out a little smaller, and fit it into the bed of the tin. While you are at it cut a strip that will cover the Arduino and keep it from possibly touching on the lid.
Place your board and battery back into position, cover up the Mini.
You could use some small dabs of hot glue to secure everything in place, but I find that the foam does a fair job at keeping things in position, and this will simply be sitting in a pumpkin. It will be easier for me to reclaim the parts should I need them before next Halloween by not gluing, so I didn't.
Most credit card sized Fresnel magnifiers have a small 1/2 inch - 3/4 inch regular style lens built in as well (The small circular lens). I wanted to use this to sort of give it a more finished look and also because I figured it couldn't hurt the performance much...most LED flashlights have a small lens too. Plus I had the lens, and had been looking for an excuse to use it. (I will be keeping the other piece for another experiment or project.
So snip or score and snap it off and hot glue it into place. Looks awesome. Way more fun and lamp-like now.
For a final touch, I gently sanded away any advertising, added a little rubber bit to the button and closed it all up.
Now go put it in a Jack O' Lantern and enjoy being multicolored and sophisticated like everybody else on the block!
I hope you had a good time and I really hope that my little library is helpful to someone else out there.
Okay I shot the video before sanding...You got me.
Step 5: Gourd It Up.
Happy Halloween everyone, make it geeky, keep it scary.
Participated in the
Halloween Decorations Challenge
Participated in the
The Mad Science Fair
Participated in the
Participated in the
Make It Glow Challenge
1 Person Made This Project!
dapackers made it!