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

Other Parts

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))

#define F_CPU 1000000
void dispClear()
  PORTB = ~0b00000000;
int main()
  DDRB = 0xFF; //For those of you who have never read C before the double slash indicates a comment.  This sets the pins of the avr as an output
  char x = 10;  //x is used to set the delay legnth.  Increasing the value give a slower switch between pixels, decreasing, a lower
  while(1)  //While(condition is true); {Do This}  (True in C is 1)
      PORTB = ~0b00010001;  //My friend's name is Zoe so I drew out the characters on graph paper and then imputed them into PORTB.  The first three zeros don't matter because there are only five led's connected.  A one in one of the remaining five spaces indicates that the LED is on, a zero, off.
      _delay_ms(x);  //delay in miliseconds
      PORTB = ~0b00010011;
      PORTB = ~0b00010101;
      PORTB = ~0b00011001;
      PORTB = ~0b00010001;
      dispClear();  //Open space between characters
      PORTB = ~0b00001110;
      PORTB = ~0b00010001;
      PORTB = ~0b00001110;
      PORTB = ~0b00011111;
      PORTB = ~0b00010101;
      PORTB = ~0b00010001;
      _delay_ms(x*5);  //The word is done so for clairity I have a bigger space between words

Now follow the instructions on page 4 to compile this code and send it to your AVR.
Nice DIY project. :) Can be ATTINY45 programmed via the Arduino?
<p>yes.</p><p>(realize post is 2 years old, posting for others who scroll by... like you)</p>
<p>Hy , if you help me , can you give the code to write STF with PORTB , I would be grateful ! Thanks!</p>
<p>Very nice projects ...thanks for sharing .</p><p>Build_it_Bob</p>
where do you write the code sorry im new to AVRs
I generally write in good old emacs when I'm on a *nix system, though I am partial to Sublime Text 2. Neither are IDEs.
Hi! <br>First of all nice tutorial! <br>But I have one question, it is written in the Attiny45 datasheet that it has only 2 PWM pins, am I misunderstanding something? <br>Have a nice day!
*Note: OC stands for output compare. In the datasheet it says that the 2nd T/C has separate Output Compare Registers. This is what's really important to us. One output compare reg. gets us one easy channel of PWM.
Yep, that'a a little tricky. In the data sheet it says there's a Timer/Counter that has 2 PWM outputs. But, if you look right underneath that, there's the High-Speed T/C. This T/C can also do PWM on some other pins. <br> <br>In general, I look at the pinout and see how many pins have a separate OC** designator, as those are the pins that can be used for PWM. <br>Cheers!
Great instructable!<br>This evening i got the rgb scroller working with the abby version, and i got an idea for a mod.<br>My idea is to read a 10 k potentiometer and to select a color based on the value.<br>So if the potentiometer is a 10 bit value i could break the value in blocks of three that'll be the codes for the color components, and if the last bit is set it scrolls through colors.<br>I'm loosing some resolution there, but it's ok.<br>I'm just starting to work with microcontrollers and i have had experience only with arduino so far. What do you think, could this work?<br>Can you give me some advice on how to proceed?<br>
I think this could work. If you didn't mind (relatively) low resolution you could use the number from the adc to specify where in the code you are and have the code be near the same as I have already written. Since you're good with arduino I'd try out your ideas there and then translate them into code for the attiny45.
can you give the code for writting robot
I'm not sure what you mean by that statement. Could you explain?
as you rote zoe with pov can you give the code to write robot with pov
It would look something like this:<br><br>00011111<br>00000101<br>00011010<br><br>00011111<br>00010001<br>00011111<br><br>00011111<br>00010101<br>00001010<br><br>&quot;o&quot; again<br><br>00000001<br>00011111<br>00000001
lol thank you
I'm having some trouble modifying the code. If i try something like y=bright(); the hex file gets almost 10 times bigger and i get the following <br><br>&gt;&gt;avrdude: ERROR: address 0x1010 out of range at line 257 of new.hex<br><br>Can I use the adc value directly or am I missing something? I'd like to change the wait time with a pot so i could &quot;freeze&quot; a color or fast forward if i don't like it<br><br>Sorry if this is a noob question, but i haven't got much experience with microcontrollers.<br><br>Thank you!
I'm not sure why &quot;y = bright();&quot; would kill the hex file. You will need to change the bright() function so that if the pot at a certain point stops the cycle. Something like this:<br><br>char bright()<br>{<br> ....<br> ....<br> (just before the return statement)<br> while(adc &lt;= 1); //This'll do nothing while the adc is less than 1<br>...<br><br><br>You'll need to change the &quot;_delay_ms(y);&quot; to &quot;_delay_ms(bright());&quot;
Hi ogama8, I like your intruc :) but could you please specify if in the _delay_ms(x)?<br>Should I put a value for the x in there? How is this sentence written. I tried both with a value of 100 and x alone.<br><br>Maybe could it be the char x = 10; that should be change?<br><br>I did recompile this twice but could not get anything except Kligon stuff!!!<br><br>Thanks a lot for your time<br><br>Eric
Yes, char x = 10; should change. If you want the lights to go faster you'd lower the value of x, like so:<br><br>char x = 2;<br><br>char specifies the type of variable x is, and = 2 sets the value of x when it's called elsewhere. For example:<br><br>char x = 10;<br>.....<br>_delay_ms(x);<br><br>because x == 10 that means that _delay_ms(x) is the same as _delay_ms(10).<br><br>Since I have multiple instances where I'm using a _delay_ms() it makes the value easier to change.
Yes, such a great answer!! That make so much sence. <strong>Thanks a lot..</strong>.
Is there a way to speed up the flashing on this project? So that it is more like a bike light?
Yes. Lower the value of x.
Please update this post with the applicable code. The zip files which were previously hosted on a free hosting site have been deleted due to inactivity.
All done.
Thanks :)
I built the purse light, but it does not work, I am hoping that someone can help me out. I used avrdude to flash the chip with the make.hex file. I built everything, but it doesn't turn on. I am new to these projects, so I do not know appropriate troubleshooting steps. <br><br>I did run a wire directly from the battery (+) to the 2nd pin of the chip, and one of the leds turned on. Running it to the 3rd pin turns the other on. Does this mean that the chip wasn't programmed correctly?<br><br>Thanks.
Are you sure that you have the resistor from pin 1 to 8? What about the ground on the chip (pin 4)? Did you solder directly to the chip or use a socket? Could you upload a picture of both sides of the board? That'd really help.
Yes. I rechecked those connections. Interestingly, I rebuilt the project on a breadboard with the original LEDs. It didn't work, even though I knew that the LEDs worked. Then, I tried some different LEDs and they did work. I put those back into the original circuit board (what I took a picture of) and it worked.<br><br>Do you think that you could add some information on how to compile a *.c file?
I'm glad it's working now.<br><br>I have no idea on how to compile a .c file on AVRDude. If you do decide to use emacs you simply press Alt-x, type compile, press enter twice and you will (hopefully (if your code is correct)) end up with a hex.
Also, could someone help me with the programming part of this project? I have avrdude and avrstudio installed. I do not understand how I can take the modified *.c file and convert it back into a .hex file.
What settings did you use to burn the fuses on the chip?<br><br>Thanks!
Thanks man , these are really cool , Ive got these all going now im lovin the AVRs. Your instructables are really good. The only other question I had was how to beableto read the name flasherI got it going fine dude but Icounlnt figure out how to read it . did you put it on a wheelor somthing?<br>
I took a long exposure pic in the dark. A wheel will also work. You have to move your hand from left to right. Try starting out slow and then speed up until you see it. You can't focus on it too much.
Wondering about the Abby varrient file you have there schematic?
Ah. I forgot about that one. It's new since this was written. The Abby Variant adds a photo-resistor on pin 2. You hook one end to Vcc and the other to the second pin. You also have to hook up a 10k resistor between that pin and Gnd, too. This gets read by the AVR and turns the light off if there is enough light. I'm working on another version that automatically turns off after a pseudo-random time so it wont go all night.
Sorry I meant attiny45 or attiny12 ..
This instructable was written for the 45. The 12 will not work any PWM application but will work for the Name Flasher. I'd change the value for &quot;MEGA&quot; to 12. Let me know if that doesn't work.
Anyone know how to change the code to use a aattiny13 instead? that would be radd!
You will have to go into the make file with your text editor and change the entry for &quot;MEGA&quot; to 13 (I think). Sadly the attiny13 only has 2 PWM pins so you won't be able to do the color scroller *easily.* You could hook it up to some transistors etc. but then it's a real pain and it gets bigger. The purse light also won't work because it is using different pins for the PWM. I can work around these problems for you if you like but I'm on vacation and don't have access to AVR's at this time. I hope this helps!
Thanks for the instructable! I was looking for code similar to this.
your zip file is not available !
Fixed! Thanks for catching that!

About This Instructable




More by ogama8:3 Easy ATTiny Holiday Gifts Bike Hand Signal Light 
Add instructable to: