Hi,

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 ?

Components
• 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

Tools
• Nose Pliers
• Wire Cutter
• Soldering Iron

Stationary
• Arclyic Paint
• Paper Tape
• Paint brush

## Step 2: 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

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

## 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
• Alternate flickering
• 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)
{

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

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

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

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

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

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

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

Dim the lights and switch on the tree.
it is very amazing to watch the animation run
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 &quot;speed limiter&quot; button (my momentary switch) in a race game :) Thanks in advance!
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.
attached picture
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
<p>Hi again :)</p><p>I now have used the Digispark a little, and I have problems with the &quot;debounce&quot; and flashing LED.</p><p>I can make the internal LED (pin1) blink with the &quot;blink&quot; sketch, and make the internal LED light with the button sketch with momentary button from +5v to Pin2.</p><p>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 :/</p>
take debounce code from my code. modify flag each time it is called. based on flag value. set high or low
<p>just can't make it work :/</p><p>I can make it blink separate, that work. and whem I use the &quot;button&quot; 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. </p><p>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 :/</p><p>I can transfer some \$\$ for your help if you have paypal :)</p><p>I've searched several sites, but cant make it work :/ </p>
<p>Hi Bjarneec</p><p>No need for \$\$ ;) </p><p>Try this</p><p>Note that if yo have loose wires / short circuit yo will face issues</p><p>Send me photos of your connections and circuit</p><p>- Amit</p>
<p>Hi again :)</p><p>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? </p><p>By the way, the problem with the &quot;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 :)</p>
<p>Dont have camera right now - but will upload monday :)</p><p>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?</p><p>When uploading the normal &quot;Blink&quot; code, then no problems appears. Only when codes assigns one of the 6 pins :/</p>
hi, you may have not connected the pin correctly and lose wiring
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 &quot;burn&quot; the bootloader, but as I see there is a lot of Info on Google to do that :)
hi, digispark should come with a boot loader. at least mine had it. you need to change pins between 0to 4.<br>also it takes 5secs to boot digispark
I know that, but im pretty lost on codes to that, so though/hoped yoy maybe could help :D<br><br>what i'm thinking about is like the picture, where im maybe replacing the &quot;relay&quot; with the DigiSpark, to activate the flashing LEDs when the momentary button is pressed, and turn them off when pressed again and so on. :)
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<br><br>why 5 ?<br>Why digispark, you can do this using ic 555
Thank you for taking your time :) its because im in a sim race League and is building an &quot;button box&quot; 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 &quot;Real&quot; 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. <br>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 :)
Hi, my internet is down. Will try and send sample cide in this week
Is it maybe possible you have an idea to the code for my project? :)<br>Need a LED to flash when a momentary Button is pushed and to stop again when pushing same Button :)
<p>enough to give you LED RGB &amp; pingpong ball and we have this effect</p>
<p>Nice</p>