Fiberoptic Wedding Reception Table Centerpieces
The wedding(s) actually took place last year (3/1 and 9/7 respectively, the first being the official "on paper" rushed ceremony to get me on my wife's insurance and the second falling on the originally planned date and celebrated with guests and a reception) but Oss encouraged me to share this project when he was doing something similar with rgb LEDs. I made 15 of these for the tables at the reception. We got the bodies with the fiberoptic sprays off eBay. They had built-in battery compartments (3xAA, which I filled with "heavy duty" cheap-os but which still apparently ran these things for three weeks continuously) but they were green plastic, so I had to spray paint them with Testors modeling paint. We chose chrome. Also, they did a lightshow that wasn't what we wanted from the factory.
The idea was to fade between the three wedding colors (Tiffany blue(thus "Moon River" in the video), Pony-boy tan and Clara Belle brown, the last two being the colors of two of our dogs) using Photoshop's RGB interpretation of those colors for PWM values. It took a little tweaking to get it even close. Also, astute makers will note that the ATTiny only has PWM on two pins native. I had to cheat the third channel to get a decent fade. It would have been nice to make use of more of the OEM electronics, but they were all SMD slagged, so I could hardly even get the LEDs off. Besides, I wanted an excuse to order some components that wouldn't seem like a completely selfish affair.
The electronics I put on cut up chunks of RadioShack perfboards. They ended up looking kind of like this:
...plus an IC, of course. I just wired the +/- lines from the battery compartments into pins 8 and 4 respectively (on this photo, Pin 1 would be lower right.) Only Pins 0 and 1 (DIP pins 5 and 6, top left) are PWM on the Tiny 45/85, so pin 2 (DIP 7) was the cheated PWM. I didn't even bother to put a power switch in-I just cut little pieces of plastic gel and put them between one battery terminal and the compartment connector, then had the hired help pull them out when they set up the tables. Worked like a charm.
The code is for Arduino as ISP (see High Low Tech) and it may seem like a lot-120 some lines-for such a small, simple result, but I am really only sharing this so others can learn from it as an example or for similar-but-different projects (not because I think other robot-makers want to duplicate the project.) I think the commenting is pretty complete:
The softPWM function is a pretty standard method. You see it and variations on it in everything from this kind of LED fading to manual servo control. It would have been just as easy to call softPWM on all three pins for each transition, but I had already written the analogWrites in when I realized I was a PWM short so why retype everything?
One thing you'll notice is that the pause at full brightness isn't consistent from function to function-pony2clara contains the pauses for both Pony and Clara's colors. If I remember right I did this because of the way I had to cheat the softPWM, but it's been like 8 months since I coded this. I don't know why it ended up that way anymore. I just know it didn't work when I tried to do it with the functions mirrored. (It would be nice if Arduino let you do class construction in the main sketch, but that wouldn't have helped me here apparently.)
Sorry it took me so long to put this up.