Introduction: ATTiny 85 Controlled Festive String Lights

Whilst browsing eBay I came across these strings of 50 addressable LEDs using the WS2811 chip, whilst I don't think they are really designed to be used as fairy lights they do work well and they look awesome in the tree. It would also be possible to change the colours to make them suitable for any number of holiday themes. As it's nearly Christmas I have gone with lots and red and green as well as some patterns that use a lot of random colours and of course what addressable LED project would be complete without a rainbow.

The Micro controller is an ATTiny 85 and there are 3 button that change the mode and the speed of the patterns in what I hope is a fairly intuitive way.

Im a big fan of the ATTiny85 as it works well with the Arduino IDE, its cheap and from my experience its quite a resilient chip.

The total cost per set is less than £15 and could easily be completed in a weekend with only basic tools.

Temporary parts needed:

  • Arduinouno or equivalent for programming the ATTiny
  • bread board and jumper wires for testing and programming the ATTiny
  • soldering iron and solder
  • hot glue gun

Parts used for the build:

I have included links to some of the items on Amazon to help identify them, its by no means the best place to purchase them and you should shop around.

The 3 momentary push switches can be any kind you like but you may need to adjust your design to suit your switches. I had some with a longer button and 2 legs that makes them well suited to this project as I can poke them through a hole in the top cover and hot glue them in place from the bottom.

* This is copied from the Adafruit NeoPixel Überguide and explains the need for the capacitor and resistor.

Before connecting NeoPixels to any large power source (DC “wall wart” or even a large battery), add a capacitor (1000 µF, 6.3V or higher) across the + and – terminals as shown above. The capacitor buffers sudden changes in the current drawn by the strip.Place a 300 to 500 Ohm resistor between the Arduino data output pin and the input to the first NeoPixel. The resistor should be at the end of the wire closest to the NeoPixel(s), not the microcontroller. Some products already incorporate this resistor…if you’re not sure, add one…there’s no harm in doubling up!

Other things to note:

Power use is always somthing you need to think about with addressable LEDs. To work out how much power you will need simply take the number of LEDs in your array and times it by 60 as each LED can draw 60ma

This is a string of 50 so 50X60 is 3000 or 3 amps whilst this is quite a lot of power its worth remembering that they will only use that much if on full brightness on all 3 colours. You can arrange your code to avoid this or use the setBrightness() command to limit it. in testing I have found my setup work well on a 2 amp power supply.

I would highly recommend reading the Adafruit NeoPixel Überguide( ) as it's explains everything in much better detail than I can.

Step 1: Drilling


There are a few holes to dill into the project box.

  • 1x 8mm in the back for the power socket
  • 3x 2.5mm holes in the front for the 3 leads of the LEDs or 1 hole that's larger enough for all 3 leads to come out of.
  • 3x 3.5mm in the top for the buttons

Its best to pilot the 8mm hole but as the box of a soft plastic its easy to drill and shouldn't give any problems

Step 2: Soldering

Tin the connectors of the power socket, inset into the box and tighten the retaining nut.

Place the buttons in the holes and hot glue or epoxy them into place. I have pulled one leg from each of the buttons together and soldered them together so we will only need one 5 volt supply to all 3 buttons.

The LED strings have 2 additional wires that we don't need attached for this project so we can cut them off. I have cut them close to the top at slightly different lengths so they can't short out. Keep these wires as we can recycle them inside the box

I have also cut the connector off as we will be soldering directly to the wires, Cut as close to the connector as possible.

The prototyping board fits inside the project box very nicely so didn't requite any cutting.

Solder the IC socket onto the board somewhere near the top, this allows us more space at the bottom for the other components and to connect to the LED string.

Solder wires to physical pins 5, 6 and 7 for the buttons, connect the wires onto the pull down resistors, that in turn will connect to Ground

  • Pin 5 = Mode button
  • Pin 6 = Speed minus button
  • Pin 7 = Speed plus button

The data wire for the LEDs connects to physical pin 3 so solder another wire on and connect the other end to the 300-500Ω resistor somewhere near the bottom of the board.

We can use the wires we cut off the LED string as our main power wires

  • Connect Pin 8 of the IC socket, a wire for the buttons and the main LED string RED wire to 5V
  • Connect Pin 4 of the IC socket, all 3 pull down resistors and the main LED sting WHITE wire to Ground

Solder the 5v button wire onto the common for the buttons. Attach each button to the correct Pin of the IC. Hopefully you can see in the images that I have bought the wires that connect to the IC to the centre of the board with the resistor on one side and button on the other.

I have place the capacitor on the board but it would have been easier to connect it to the socket legs.

Once the board is complete inset the 3 wires for the LED string through the holes and solder onto the board. Connect the power wires to the socket. These sockets have the centre pin (normally V+) connected to the shorter leg but its always best to double check.

Before gluing everything in place its best to check everything is working as its easy to miss a connection.

Check out the the next step for uploading the code

Step 3: Upload the Code and Test

The Code

The code is relatively strait forward and consists mainly of 2 parts. One part of it looks out for a pin change on pins 5,6 or 7 (the interrupt or ISR) then changes a variable depending on which button is pressed and the other part (the main loop) controls the LEDs depending on a variable that set either at power on or during the ISR.

When you press the Mode button the IC runs the ISR. The ISR checks if the mode button is HIGH and if so add 1 to the show counter then returns to the main loop. The same is basically the same for the speed buttons.

The main loop uses While statements to run the animation that corresponds to the show counter. If the show counter changes the loop will move onto the While statement that matches the Show counter.

There are 9 animations in the code but you could easily add or remove some. You can also change what animation is used at the start by changing the variable on line 4

Feel free to change anything you like but keep in mind that the program won't break out of the while statement until its finished running it or it breaks from inside. This is only really a problem if you are using long delays. You can use a IF statement like the one below in the animations to check if the Show Counter has changed and break out of the While loop if it has.

<p>if (showCounter !=4){<br>      break;
    }     </p>

The Speed of the animations is set using the delay function so to make things move faster you need to decrease the delay.

The maximum delay is set on line 163 and 164, This could be increased if wanted.

A few if the animations will reset the speed to a minimum level if it's set too low using the buttons. This is partly because the effect will be lost if its too fast and partly as fast flashing lights can be problematic for some people.


You will need to have the Adafruit NeoPixel library installed on your system

Thanks to Ian Cumming for uploading this instructable that covers everything you need to know about programming the ATTiny85.


Once the code is uploaded to the IC you should be able to plug it into the socket. Make sure that the little dot on the top of the IC is in the correct place and you should be good to go.

Power it up and make sure everything is working.

Step 4: Glue It

If everything is working as expected then hot glue the board down into the box, It shouldn't have a lot of force to deal with so I wouldn't go to crazy add some more around the wires for the LEDs to provide some strain relief.

Pop the lid on and you're done.

Step 5: Other Thoughts and Ideas

Tiny Or Nano

Whilst I love the ATTiny 85 chip it has some limitations, Mostly that its a little tricky to update the code on it. Another option would be to use somthing like the Arduino Nano, whilst its a little more expensive and overkill for a project like this it has the advantage of an onboard USB port making it possible to change your code very easily.

The Potentiometer Potential

It would be possible and maybe even easier to use a Potentiometer in place of the speed adjustment buttons.

Longer Strings

The LED strings are designed to be connect together but keep in mind the power usage.

Direct Power

You could use an old USB cable or 5v power supply and delete the USB to DC cable and DC socket

Make it Glow Contest 2018

Participated in the
Make it Glow Contest 2018