## Introduction: LED Tree With DigiSpark

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

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

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

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

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