Introduction: LED Tree With DigiSpark

Picture of LED Tree With DigiSpark


I wanted to make a LED Tree for few years but did not get good instructable on internet. I found some which used simple lights wound round a rigid wire structure. These lights are bit fragile and get spoil easily.

I had made everything from scratch, I used 3mm yellow leds with Digispark ( ATTINY85 )

Step 1: What Do We Need ?

Picture of What Do We Need ?

• 60 : 3mm Yellow LEDs
• 02 : 5MM Red Leds
• 01 : Digispark
• 01 : 4 AA Battery holder
• 04 : AA NIMH rechargeable batteries
• 05 : Meters CAT 5e cable
• 01 : Plastic Pot
• 01 : Old Mobile charger
• 01 : Switch ( On/OFF)
• 01 : Push button
• 01 : Universal PCB ( 1 X 2 Inches)
• 03 : 2N222 npn Transistor
• 03 : 1K Ohms resister
• 30 : 56 ohms Resisters
• 01 : 10K Ohms resistor
• Loose wires

• Nose Pliers
• Wire Cutter
• Soldering Iron

• Arclyic Paint
• Paper Tape
• Paint brush

Step 2: Concept 1 : LED Resister Calculation

Picture of Concept 1 : LED Resister Calculation

If you are not expect on Ohms Law

R = V/I

Use this URL to calculate resister and schematic LED in parallel

• Source voltage : 5V
• Diode forward voltage : 2V
• Diode forward current : 20mA
• Number of LEDs in your array : 60

Refer to the image for LED Schematics

The wizard says: In solution 0:

• each 56 ohm resistor dissipates 22.4 mW
• the wizard thinks 1/4W resistors are fine for your application Help together,
• all resistors dissipate 672 mW together,
• the diodes dissipate 2400 mW
• total power dissipated by the array is 3072 mW
• the array draws current of 600 mA from the source

So my LED tree will need 5V 600 mA and 5.5Watts

I am going to divide the Circuit into 2 sets of 30 LEDs

Step 3: Concept 2 : Circuit

Picture of Concept 2 : Circuit

In the circuit: I am using

• Two 2N222 NPN transistor
• Connected pins P0, P1 and P4 from Attiny85 ( PWM capable pins) to LEDS
• Attiny85 P2 / Int0 to button
• Using 4 AA Batteries

I used 1K Ohm resister between Transistor and pins of attiny85 to prevent reverse current from transistor

PS: The Pins on Attiiny85 are numbered differently

Test your circuit on bread board before we build circuit and adjust the code

Step 4: Concept 3 : the Code

For the code I wanted to put 4 animations

• All LEDS on, wit 2 RED Leds fading on PWM
• All fading on PWM
• Alternate flickering
• Alternate fading on PWM
• And Loop each for 30 Secs

I used Digispark on Arduino Studio to code it.

Also used an hardware interrupt with debounce to change animation.

I did not have schmit trigger chip to use the hardware interrupt, So used debounce and attachinterrupt in unique combination

Partial Code :)

void setup() {
// declare pin 0 and 1 to be an output:

pinMode(led0, OUTPUT);

pinMode(led1, OUTPUT);

pinMode(led4, OUTPUT);

pinMode(button, INPUT);

// Hardware Interrupt on Physical pin 7, logical pin 2)

attachInterrupt(0, flag_interrupt, CHANGE);


boolean debounce(boolean last)

boolean current = digitalRead(button);

if (last != current) { delay(5); current = digitalRead(button); }

return current; }

void flag_interrupt()
{ // read button, pressed set Flag++

currentButton = debounce(lastButton);

if (lastButton == LOW && currentButton == HIGH) { Flag = Flag + 1; }

lastButton = currentButton;


Step 5: Prepare LEDs

Picture of Prepare LEDs

Connect, 3mm yellow LEDs and soldered two with a 56Ohms resisters in series.
D1.anode : colored wire
D2.anode : D1.cathode
D2.cathode : white wire

Separate the wire pairs from a cat5e cable and solder it on the leds in series with colored on Anode and white on cathode or resister end

Use heat shrunk tube to seal and secure the leads from getting short

Make 30 such bunches

Step 6: Make Tree Structure

Picture of Make Tree Structure

Use a hard rigid wire and cut them as required and use some imagination

I had made 5 branched and then added 2 more later (without the rigid wire)

Paint the metal wire with red-oxide to prevent it from rusting and decoloring later

Get a plastic pot and use card board as base as stand for the tree

Step 7: LED on the Structure

Picture of LED on the Structure

Now one at a time wound / fix the leds on each branch, use paper tape as it is easy to work and can be painted later

All Anodes are connected to Battery or positive directly

Separate the negative / cathode, wires into 2 bunched for yellow leds and 1 for red

Connect soft wires as shown and seal the base using card board

Please test the leds after every step, just to make sure there are no breakages or shorts

Paint all branches with arcylic colors as you want. I used brown and green color

Step 8: Prepare Circuit and Pot Enclosure

Picture of Prepare Circuit and Pot Enclosure

Use a universal pcb and place the components on it. Carefully solder each component as per the circuit diagram.

Use different color wires so that it is essay to troubleshoot later.

Attach switch, power in and push button on the pot using PVC solvent cement.

For some reason I am unable to use hot glue gun, not strong enough.

I had used 600mAh batteries but they get used up very fast.
So you can replace them by higher rating batteries it by pass the charger to power circuit instead of charging battery

Step 9: The Charger

Picture of The Charger

I had an old Samsung mobile charger, which over a period of time did not work with my phone beside to lose connector.

I clipped the connector end and soldered another plug matching the in plug on the pot

this charger can be used to charge battery or power our tree

Step 10: Dim the Lights

Picture of Dim the Lights

Dim the lights and switch on the tree.
it is very amazing to watch the animation run


Bjarneec (author)2015-07-24

As you seems to be very good to DigiSpark - Can you maybe help? I Think im going to buy digispark to this project; i have a momentary switch (N/O) that should activate 4/5 flashing LEDs. And of course power off again when pushing again. Is it possible with digispark? The plan is that the LEDs should flash when im pushing the "speed limiter" button (my momentary switch) in a race game :) Thanks in advance!

Amit_Jain (author)Bjarneec2015-07-24

Digispark is based on attiny85, which has 5 pins that can be used as only or output. in my project I used 3 pins as output and one as input. when I press the input/momentary button the code ,/ output changes on other 3.

Bjarneec (author)Amit_Jain2015-08-01

attached picture

Amit_Jain (author)Bjarneec2015-08-07

code for you is available in Arduino ide, as in the screenshot. just change pins as your need. you may want to also read how to code a digispark using Arduino ide

Bjarneec (author)Amit_Jain2015-08-30

Hi again :)

I now have used the Digispark a little, and I have problems with the "debounce" and flashing LED.

I can make the internal LED (pin1) blink with the "blink" sketch, and make the internal LED light with the button sketch with momentary button from +5v to Pin2.

But how do I build those 2 together so the internal led (pin1) is flashing when the momentary button attached to +5v to pin2 is pushed and then turns off when pushed again? I know it have something to do with read LOW/HIGH but i'm not able to figure it out :/

Amit_Jain (author)Bjarneec2015-08-30

take debounce code from my code. modify flag each time it is called. based on flag value. set high or low

Bjarneec (author)Amit_Jain2015-09-05

just can't make it work :/

I can make it blink separate, that work. and whem I use the "button" then if I push the momentary button it light up for 5 sec and turns off again. I have to keep the button pressed to keep the LED turned on.

Can you maybe help with the code for the LED on pin 1 to flash when momentary button is pushed once, and turn off when pushed again? I simple cant make it work :/

I can transfer some $$ for your help if you have paypal :)

I've searched several sites, but cant make it work :/

Amit_Jain made it! (author)Bjarneec2015-09-05

Hi Bjarneec

No need for $$ ;)

Try this

Note that if yo have loose wires / short circuit yo will face issues

Send me photos of your connections and circuit

- Amit

Bjarneec (author)Amit_Jain2015-09-07

Hi again :)

Now I soldered the pins, so no loose connections. But the code you attached only make the led constant on - what do I need to make it flash instead when pushing momentary button?

By the way, the problem with the "constant flashing led when moving my finger around(without touching it) must be an internal failure in the board, and the seller have sent a new one :)

Bjarneec (author)Amit_Jain2015-09-05

Dont have camera right now - but will upload monday :)

I see something strange - your code doesn't seems to work, nothing happends. - BUT when i'm uploading any code with buttons or other assignments to one of the 6 pins, then the onboard LED (pin1) is flickering and going on off when my finger is about 1 cm from the board, but NOT touching it :/ That is a kind of weird. Do you think this board is poor assembled or something?

When uploading the normal "Blink" code, then no problems appears. Only when codes assigns one of the 6 pins :/

Amit_Jain (author)Bjarneec2015-09-05

hi, you may have not connected the pin correctly and lose wiring

Bjarneec (author)Amit_Jain2015-08-09

Thank you very much!! Just ordered a DigiSpark from eBay, so Im testing when its arrived in 14 days or something :) is there something I need to pay attention to? I know I have to "burn" the bootloader, but as I see there is a lot of Info on Google to do that :)

Amit_Jain (author)Bjarneec2015-08-09

hi, digispark should come with a boot loader. at least mine had it. you need to change pins between 0to 4.
also it takes 5secs to boot digispark

Bjarneec (author)Amit_Jain2015-08-01

I know that, but im pretty lost on codes to that, so though/hoped yoy maybe could help :D

what i'm thinking about is like the picture, where im maybe replacing the "relay" with the DigiSpark, to activate the flashing LEDs when the momentary button is pressed, and turn them off when pressed again and so on. :)

Amit_Jain (author)Bjarneec2015-08-02

hi, give me more details about the use, I understand you want to light 5leds when you press button on some kind of game controller

why 5 ?
Why digispark, you can do this using ic 555

Bjarneec (author)Amit_Jain2015-08-02

Thank you for taking your time :) its because im in a sim race League and is building an "button box" for the activities in game like lights on/off, pit speed limiter and so on. Then I have a old joystick i soldered wires to an have a momentary switch instead of the "Real" button on the joystick. Im thinking that I Would like to activate the 4/5 Flashing LEDs when the pit speed limiter is activated with a push on the momentary button,(seen on the pc as a push on the joystick) and deactivate when pushing again, turning on when pushin again and so on.
I though of digispark as it seems pretty cool and Can do a lot when the code is learned :) (and most inportant really cheap on eBay) :) Thanks again :)

Amit_Jain (author)Amit_Jain2015-08-01

Hi, my internet is down. Will try and send sample cide in this week

Bjarneec (author)Amit_Jain2015-07-26

Is it maybe possible you have an idea to the code for my project? :)
Need a LED to flash when a momentary Button is pushed and to stop again when pushing same Button :)

rlitwiński (author)2015-06-15

enough to give you LED RGB & pingpong ball and we have this effect

Amit_Jain (author)rlitwiński2015-06-15


About This Instructable




Bio: I am IT professional, living in Bangalore, India. As new gadgets come out everyday, we indulge in spending significant time and money on these gadgets ... More »
More by Amit_Jain:Simple Mario LampPaper Lamp for DiwaliRecycled Portable Bluetooth Speakers
Add instructable to: