Frosty Lamp Project

Andres Lopez
Published in
8 min readJan 24, 2017


The Frosty Lamp Project is a simple, yet fun project involving an AVR microcontroller and LEDs. The AVR microcontroller makes it possible to run software for your hardware projects. It also eliminates the need for many components. For example, some microcontrollers eliminate the need for an external pull-up resistor. There are so many internal features that the AVR microcontrollers contain. Simply read the manufacturer’s data sheet to see a list of features. You can find the ATTiny85’s data sheet here.

In this tutorial you will learn to build a decorative frosty lamp, and you will program patterns that the LEDs will dance to. Let’s get started!

If you would like to check out the source first, follow this link:

What you will need:

  • An AVR microcontroller. (This tutorial features the ATTiny85.)
  • An AVR programmer.
  • A computer.
  • 5 LEDs. Colors of your choice.
  • A piece of prototype board.
  • A 8-DIP socket. (If using the ATTiny85, otherwise choose the appropriate DIP socket size for your microcontroller.)
  • 20MM power switch.
  • 2 AAA batteries.
  • Wires, 22 gauge or 20 gauge is fine.
  • Electrical tape.
  • A jar with lid.
  • Glass etching cream. (Make sure to read the label about the time it takes to take effect. Some take days… let’s just say I learned from experienced.)
  • Sponge brush.

Let’s start by cleaning and etching the jar. I am using a burnt out Bath and Body Works candle jar. Start by removing any labels from the jar. If the labels are difficult to remove use an adhesive or nail polish remover. Simply apply the remover solution and scrape with a hard plastic edge. Rinse and dry the glass.

Now let’s etch the glass. Before you start, make sure that you are wearing proper eye and hand protection. Etching cream is a toxic chemical and must be used in a safe manner. Now that you are protected, start by dabbing an even layer of cream around the outside of the glass. After you are done, let the cream sit on the jar for about 20 minutes.

Now that some time has passed, rinse the jar with cold water and gently scrub the cream off. Air dry the jar after all the etching cream has been washed off.

Etched glass

If you are using an external power switch, then you will need to drill a hole on the jar’s lid. The power switch in this tutorial measures 20mm in diameter. The lid for the Bath and Body Works jar is made from thick aluminum, so a soft metal drill bit was used to make a hole. Insert the switch in the lid.

Now for the exciting part! The circuit is actually very simple. Each LED anode (positive lead) will be connected to a pin on the microcontroller. The positive wire from the battery will connect to the switch. The second lead from the switch will be connected to the microcontroller’s Vcc in pin. Lastly, connect all of the ground leads to the ground wire from the battery. You can recycle the batteries and make a new one once the juice is drained from this homemade battery pack.

Prepare the wires. You will need a total of 14 wires. Cut 6 pairs to same length. Each pair should be a slightly different length. The other two wires will be used to connect the switch to the circuit. Cut those two wires long enough to reach the switch leads to where the circuit will be placed, then strip the ends of the wires.

Add the DIP socket to the prototype board. I set it a little offset from the center. Pay extra attention to the direction of your DIP socket. You will need to match the half circle grove to the top of the microcontroller. Pin1 is designated by a small dot next to it.

Next, solder a wire to each of the pins that will control the LEDs. For the ATTiny85 we are using the pins: PD0, PD1, PD2, PD3, and PD4.

Then, solder the positive lead of the LED to the wire that connects to the pin on the microcontroller. The positive is usually the longest lead (if it hasn’t been cut). Another way to tell which is negative and which is positive is by looking for a straight edge on the LED bulb. The straight edge will be on the negative side. Trim the leads off the LEDs if they are too long. Do this for all five LEDs.

Now, let’s solder all the ground wires. We will be connecting all of the ground wires to the same area. So, let’s start by connecting a wire to the ground pin on the microcontroller.

Now, make connections to all the LEDs from ground.

That blob of solder is all ground…

Everything is connected, but we are missing a key component to this project — a power source. In this tutorial we will be making a simple power pack made from two AAA batteries, foil, some wire, and electrical tape. First, place the batteries next to each other while pointing in opposite directions. Then, place some aluminum foil under the batteries connecting negative to positive and secure it with some electrical tape.

Next, wrap the batteries with tape nice and tight.

Now, we need to connect the wires to the ends of the battery pack. Make sure to mark the negative or positive wire. You can use different colored wire or a piece of tape on one of the wires. I made a little flag out of tape to mark the negative wire.

Secure the wires with more tape.

It is time to connect the battery to the switch and microcontroller. Solder the positive wire to the empty end of the switch. Then, solder the negative wire to the negative pin of the microcontroller.

Ground to the ground wire on the chip. Positive to the switch.

Congratulations! You have completed the circuit. It is time to flash the firmware onto the ATTiny85. I am using the USBASP v2.0 programmer by LC Technology ( Another good choice is the FTDI Basic Breakout — 5V ( Make sure to read the usage notes on the programmer of your choice.

We need the AVR toolchain, before we can jump into the code. If you already have the AVR toolchain installed on your computer, then you can skip this part. There are many ways to get all the packages that you need for compiling and flashing onto an AVR chip. If you are on MacOS then the easiest is to install the CrossPack bundle ( To install on Linux follow the instructions on the avr-libc homesite ( Make sure to install the optional package avrdude. To build the toolchain on Windows then follow the following instructions:

Now that we are all set up, it is time for the code! The code is written in C, and it is using the AVR library. The AVR C library has many predefined macros that make it easy when programming for the AVR microcontroller family. You can read more about the AVR library here ( Clone or download the code from (

NOTE: If you are not using the same configuration as in this tutorial, then you will need to make edits to the Makefile. If you are using a microcontroller other than the ATTiny85, then you will need to edit the pin macros in the config.h file. Open the config.h file and edit accordingly. Use the microcontroller’s data sheet as a reference to configure your pins.

Now that all the configurations are done, hook up your microcontroller to your programmer and run the following command from the project directory:

make && make flash

After the firmware is loaded, unplug and place the ATTiny85 in the 8-DIP socket. Pay extra attention to the direction of the pins. Turn on the power to make sure that the LEDs start flashing.

Lastly, secure all the components with hot glue onto the bottom of the lid. You may also add hot glue on the exposed wire and solder to avoid shorting the circuit.

It is time to place the lid on the jar and flip the switch!

Bonus round!

It is fun to have the lamp run these preprogrammed patterns, however it would be so much more fun to create patterns of your own. First, let’s take a look at the config code.

The first two macros are for the number of LEDs hooked up, and also the speed of fading. Below that are the patterns. An LED is controlled with the following structure: LEDs byte configuration, operation, and delay in milliseconds. For example,

int8_t patterns[][3] = {
{ (1 << LED_1) | (1 << LED_3), TURN_ON, 100 },

In the example above, we are turning on LED one and two with a delay of 100 milliseconds of wait afterwards. The different operations are as follows:

FADE_ON_DIR — Fades the LED set on.

FADE_OFF_DIR — Fades the LED set off.

TURN_ON — Turns the LED set on.

TURN_OFF — Turns the LED set off.

Mess around with different combinations and have fun!