Every year the holiday season rolls around and I get stuck on what to give for my friends and family. People always say that it’s better to make the gift yourself than buy it at a store so this year I did just that. The first displays a name or basic image when waved through the air, the second fades smoothly between two white led’s (It also has a safety pin to attach it to clothes or a purse), and the third is a mood light of sorts, scrolling seamlessly between colors. All are under $15 and are easy to assemble in less than an hour. You could also give these instructions as well as parts as a gift to someone interested in learning electronics.
Note: A basic level of soldering is assumed. However, unlike my previous instructable I will gloss over how to program an AVR. I really hope that this helps people who are trying to get started in electronics. I remember when I was there and will be happy to take any questions you may have. Remember there are no stupid questions! I have left it open to you to determine how you will lay out your circuit board in hopes that you will come up with a new way of displaying the simple circuits I have drawn out. Please post pictures once you are done, I can’t wait to see what you come up with!
Parts for All of the Projects
N = number of projects
xN ATTiny45 (www.digikey.com)
xN 8-pin DIP socket (RadioShack)
x 1 Large Perf Board (I got mine at RadioShack)
xN 3v Coin Cell Battery and holder (RadioShack)
x1 Programmer (I use this and the supplied makefile will be configured to use this one)
x2N Resistors, one 10 ohm and one 10k ohm (RadioShack)
Here’s a picture of the three completed projects:
Step: 1 The Name Flasher
x5 DIFFUSED 3mm LED’s (RadioShack)
This project uses persistence of vision to display an image or text when moved rapidly. It works better when it’s dark. With the AVR we are switching between LED’s faster then the eye can see we can create a picture in the air with very few components.
The Code: (Download the .zip file at the bottom of the page for the code, makefile, etc. (That code does not have the extensive comments that this code does but if this code doesn’t work, try the one in the zip file))
Step: 2 The Purse Light
x2 LED’s NON DIFFUSED (RadioShack)
This project fades smoothly between two LED’s. My mom wanted something to go on her purse to help her bee seen at night. I felt like a flashing bike light would draw too much attention so I made this
It uses PWM (Pulse Width Modulation) to give the effect of dimming and brightening. What is actually happening is the led is flashing faster than the eye can see at varying intervals to simulate a change. You can see this more clearly when you wave it in of your face as you would with the Name Flasher. The code can be downloaded at the end of this page. See page 4 on how to compile to your AVR.
Instead of commenting the code here I’ll briefly explain the concept. PWM is generated by a timer. Each clock cycle the timer counts up one. When it reaches a certain value (In this case OCR1B) it changes the state of a pin (In this case OC1B). To get the LED’s to “switch off” I wired the other one to [OPPOSITE]OC1B (That’s what the bar across the top means). Then we use x to increment and decrement the amount of time for the LED’s to be on.
Step: 3 The Color Scroller
x1 RGB LED (diffused is better) (RadioShack)
This to me is a classic. I have always been fasinated by lights like this and find them very calming so naturally I wanted to make one. Also their visibility in society gives them a real WOW factor. “You MADE that?!”
The code is nearly the same and, in my opinion, easier to read. You can download the at the bottom. This time we provide a PWM’d pin for each grounding pin on the RGB LED. In this way we ground through the chip. Volts can be measured as the difference between two points.
This last instance is what we are doing when we ground through the chip. When there are three volts on both sides, per say, there are not enough volts to drive a LED. So to fade between colors we chose a color and another color. Set one equal to x and the other equal to 255-x or the INVERSE of x. Like we were doing in the previous project. Now go to step 4 to program.
For more detail: 3 Easy Holiday Gifts using ATTiny microcontroller