3 Easy Holiday Gifts using ATTiny microcontroller

Summary of 3 Easy Holiday Gifts using ATTiny microcontroller


This article details three affordable, DIY holiday electronics gifts using the ATTiny45 microcontroller. Each project costs under $15 and takes less than an hour to assemble, assuming basic soldering skills. The first is a "Name Flasher" utilizing persistence of vision to display text when waved. The second is a "Purse Light" that smoothly fades between two LEDs using PWM for visibility. The third is a "Color Scroller," an RGB mood light that transitions seamlessly between colors. All projects share a common core component list but require specific additional parts like LEDs or sockets.

Parts used in 3 Easy Holiday Gifts:

  • ATTiny45 Microcontroller
  • 8-pin DIP socket
  • Large Perf Board
  • 3v Coin Cell Battery and holder
  • Programmer
  • 10 ohm Resistor
  • 10k ohm Resistor
  • DIFFUSED 3mm LED's (for Name Flasher)
  • NON DIFFUSED LED's (for Purse Light)
  • RGB LED (for Color Scroller)

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

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
#include
#include
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;
      _delay_ms(x);
      PORTB = ~0b00010101;
      _delay_ms(x);
      PORTB = ~0b00011001;
      _delay_ms(x);
      PORTB = ~0b00010001;
      _delay_ms(x);
      dispClear();  //Open space between characters
      _delay_ms(x);
      PORTB = ~0b00001110;
      _delay_ms(x);
      PORTB = ~0b00010001;
      _delay_ms(x*3);
      PORTB = ~0b00001110;
      _delay_ms(x);
      dispClear();
      _delay_ms(x);
      PORTB = ~0b00011111;
      _delay_ms(x);
      PORTB = ~0b00010101;
      _delay_ms(x);
      PORTB = ~0b00010001;
      _delay_ms(x);
      dispClear();
      _delay_ms(x*5);  //The word is done so for clairity I have a bigger space between words
    }

}

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

The Color Scroller
Other Parts
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.
3v-0v=3v
5v-2v=3v
***3v-3v=0v***
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

Quick Solutions to Questions related to 3 Easy Holiday Gifts:

  • What are the main components required for all three projects?
    All projects use an ATTiny45, an 8-pin DIP socket, a large perf board, a 3v coin cell battery with holder, a programmer, one 10 ohm resistor, and one 10k ohm resistor.
  • How does the Name Flasher project work?
    The project uses persistence of vision by switching between LEDs faster than the eye can see while moving rapidly through the air to create an image or text.
  • Can I make these gifts if I cannot program an AVR?
    The author notes that a basic level of soldering is assumed and states they will gloss over how to program an AVR, implying some programming knowledge is still needed.
  • What technology allows the Purse Light to fade smoothly?
    The Purse Light uses PWM (Pulse Width Modulation) generated by a timer to flash the LEDs at varying intervals, simulating a dimming and brightening effect.
  • How does the Color Scroller change between different colors?
    It provides a PWM'd pin for each grounding pin on the RGB LED, setting one color value equal to x and the other to 255-x to fade between them.
  • Are there any specific safety features mentioned for the Purse Light?
    The Purse Light includes a safety pin designed to attach the device securely to clothes or a purse.
  • What is the estimated cost and assembly time for these projects?
    All three displays are under $15 and are easy to assemble in less than an hour.
  • Does the Name Flasher work well in bright environments?
    No, the project works better when it is dark because it relies on the eye's inability to track rapid LED switching.
  • Where can I find the code and makefiles for these projects?
    The code, makefile, and other necessary files can be downloaded as a .zip file located at the bottom of the original page.
  • Can I give the instructions and parts as a gift instead of the finished product?
    Yes, you could provide the instructions along with the parts as a gift to someone interested in learning electronics.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top