(or: How I spent my Spring Break)
From the webmaster of Natetrue.com - go there for more projects!
Recently, I saw a question on Ask Slashdot that intrigued me:
The person was asking for ideas relating to building your own glowing and color changing ball. Being the kind of person to take such a general request for comments and turn it into a personal reason for living, I quickly skimmed the description on ThinkGeek and came up with these requirements for my project:
1. Must be a relatively featureless decoration
2. Must emit light
3. That light must be able to change color
4. That light must have at least 256 colors
5. Must cost less than $50 to make
6. Must be wireless, with at least a 30-foot range
7. Must be controllable by home computer
After much deliberation, I came up with the following solution:
Originally I figured I could use a Parallax Basic Stamp I microcontroller ($34), but the stringent timing requirements forced me to go with a much faster (and MUCH cheaper) PIC microcontroller, the 16F84A (about $6). The PIC16F84A microcontroller is a favorite among hobbyists (even after being superseded by the superior 16F628) and suits this purpose very well. Of course, having only used the Basic Stamp in the past, I had to learn the 36-instruction assembly language native to the PIC - this was no small task.
"Wow," you say, "how can you expect to make something wireless and still have it cost less than fifty dollars?" Well I'm glad you asked. "But I didn't ask," you say, "I'm just reading." Do you want to argue, or would you like to hear about my solution? That's what I thought. For the job of fairly-reliable wireless communication, I turn to my old friends the TX433 and RX433 modules. These are complementary transmitter/receiver pairs that operate on the seldom-used 433.92 MHz frequency. Another strong plus is that the devices are very small. The transmitter (TX433) is about the size of my thumbnail (though to be fair, I have sexier-than-average thumbnails) and will fit inside a standard 9-pin D-Sub hood. As if that weren't enough, the transmitter also has very loose power requirements (3 to 12 volts). The receiver is slightly larger and is quite finicky about its power (more on that later). Back in the day you could obtain them through TechAmerica, but now TechAmerica has turned into RadioShack.com, and along with RadioShack, their inventory has decreased to the point of phasing out these wonderful little modules. So doing a search on "RX433" revealed to me the only other online supplier of these miracle devices, a company called QKits in Canada. They go for about $6 american each. I also found some on eBay at comparable prices (and they might be more reliable modules).
Elementary color theory professes that we see color as a combination of three colors, Red, Green, and Blue. So it would appear that we should have some amount of light-emitting diodes in each color. Biblical references aside, I decided on including two of each color in my wireless color-changing non-waterproof ark. Superbrightleds.com sold some really super-bright LEDs to me at super-low prices (and they threw in a free bumper sticker!). Combined with the obligatory current-limiting resistors and the customary current-amplifying transistors, we have ourselves a display that rivals the common Taplight in brightness.
After a very small amount of looking around for suitable casing, I had to choose between the fogged globe surrounding the light in my room or the small plastic Taplight (one of a set of not four, but six) which my mom decided we couldn't live without. I decided to go with the Taplight because of its inherently durable plastic design and its abstract beauty. In the future I may wish to build it into my Magnetic Suspension Lamp which is currently floating a walnut. Does that sound unique enough? Color-changing, wireless floating walnut?
Okay, so the title for this section doesn't ring a bell for most of you . Get over it. I decided that holding an analog brightness level for an LED should not take up any of the PIC's precious time once the brightness is set. So after reading the quasi-intelligent commentary on the Ask Slashdot question, I decided to come up with my own solution . If you're at all familiar with electronics, you'll recognize the 555 timer chip. For the rest of you, it's basically a chip that pulses every once in a while. I wired it to fire at about 1 KHz, way more than fast enough to make the lights visually stable. The 555's pulses drive a trio of 7491 shift registers (for programmers, they're each like 8-position queues, and for laypeople, it's like a line of 8 people) where each clock pulse advances the shift register/queue/line one position. The front of the line is tied to the output so it ends up like a speedily rotating circular line. When a 1 appears at the output, the light turns on, and when a 0 appears, the light is off. So the brightness of the light will depend on the ratio of 1's to 0's in the shift register that's running it. This allows nine brightness levels (from zero 1's to eight 1's) for each color, Red, Green, and Blue. To set the brightness, the PIC need only momentarily sever this loop, and feed in its own sequence of 1's and 0's. Then it ties the input back to the output and lets the shift register hold its value. This is not as difficult as it first appears - thanks to the PIC's ability to 'disconnect' an output pin, a single resistor is all that's needed to allow this wonderful process to happen. After I finished this project, I realized these shift registers were unnecessary as the PIC had many clock cycles left (even running at 4 MHz) and it would have been able to hold the brightness levels just fine. Oh well!
Okay, we have three individual colors coming out of six superbright light-emitting diodes. How do we mix their light together to make a solid color? The answer is not as simple as it seems - given the Taplight's dome-like top, we must have fairly consistent color across it, not various spots of color. So for this I decided to point all six LEDs at a single point between them all, onto a glossy white surface. The mix-a-lation provided by such a surface is superb and it keeps light loss to a minimum.
As I said earlier, the transmitter will fit into a standard 9-pin D-sub hood, available at your local Radio Shack. All that needs to be connected are a few fake-like-it's-real pins, the data pin, and the two power pins. The transmitter is powered off the Data Terminal Ready pin, which the computer sets high when it opens the serial port. There is a diode in there because we don't want negative voltage when the DTR pin goes low.
Here's the cost analysis:
|2 Red LEDs||$1.20|
|2 Green LEDs||$2.76|
|2 Blue LEDs||$2.60|
Note: Things like the Taplight, the PIC programmer, the circuit board, and the miscellaneous electronic parts have been omitted because they would have brought the total above $50 (and most tinkerers such as myself have these things on hand already).
The following pages get increasingly less image-ridden and much more technical. So pay attention!
On to Page 2 - Challenges faced
Copyright © 2003 by Nathan True - wlcolor at natetrue.com