Christmas LED Tree Decoration

3 1715 Medium

Wooden Christmas tree decoration, with led rows representing string lights of a Christmas tree and a star on top of it.

projectImage

Things used in this project

Hardware components

HARDWARE LIST
1 Arduino Nano R3
21 5 mm LED: Red
23 5 mm LED: Green
11 5 mm LED: Yellow
13 General Purpose Transistor NPN
13 Through Hole Resistor, 33 kohm
3 Through Hole Resistor, 20 kohm
4 Resistor 220 ohm
7 Resistor 330 ohm
3 Resistor 100 ohm
1 Resistor 475 ohm
1 Through Hole Resistor, 680 ohm
1 SparkFun Solder-able Breadboard

Software apps and online services

Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)

Drill / Driver, Cordless

Hot glue gun (generic)

Story

 

Background

 

This project was intended as a Christmas present for my girlfriend and was also the first electronic project I've implemented. It was highly inspired by @Arduino_Jarod project Wooden LED Christmas Tree.

 

The idea

 

Wooden Christmas tree decoration, with led rows representing string lights of a Christmas tree and a star on top of it. Each row has different colors, which I'm able to control independently (as well as the rows it self) via arduinos micro-controller. This way I can bring tree to life by coding my own light show programmes.

projectImage

Designing the tree

 

Arduino nano has limited amount of dio (Digital input/output) pins, therefore I've decided to go with 13 circuit layout to build my tree. (5 rows * 2 colors) for the tree + 3 rows for the star. A single dio pin doesn't provide enough voltage (nor does it withstand enough current draw) to power any circuit of more than 2 LEDs so I've had to figure out an external power source. Luckily I've dug up an old 12 volt (max 1 amp) wall power supply and used that as a single power source for my project. I've used NPN transistors to manage power supply to my circuits using lower voltage signals from dio pins.

projectImage

Although 12V is a significant improvement over 5V arduino pin can provide, it still wasn't enough to power some of the longer LED rows connected in a series circuit. This is where I've had to use a slightly more complicated design and split my circuit load in to two parallel circuits before connecting it to the transistors collector. This way I've compensated my shortage of voltage by allowing more current draw, and as a result slightly increasing the main circuits resistance

projectImage

With most of the thinking completed, It was time to fit everything onto a pref-board. I've fitted all 13 circuits in a 2 column layout, green ones on top and reds on the bottom. I've figured it would be useful to have horizontal power and ground stripes, similar to the ones on a breadboard, so I've included those in my design.

projectImage

Cutting wood

 

Now I was finally ready to start constructing. The first activity turned out to be quite basic. I've simply cut the tree figure, a stand and drilled holes for all the LEDs.

 

Soldering LEDs

 

Next, I had to solder all the LEDs together. I've found LED legs to be lengthy enough, and avoided using any additional wires. Although it wasn't completely necessary, I've isolated soldered connections with heat wrapping wire tubes.

projectImage

Soldering pref-board

 

This was the most time consuming task by far. I've soldered all the components in a similar pattern as previously described, and then all the wires, which would later connect to my LED circuits. Hot glue turned up useful at times, to isolate the open wires from the board.

projectImage

Connecting it all together

 

After all this work, I could finally put it all together. I've glued the board to the back of a tree, connected all the wires and came up with some test code. In the end, it took some more time to debug many of the hardware issues (mainly caused by lack of soldering experience), but eventually I got it to work, and it came out beautifully :)

projectImage

Schematics

SIngle color series circuit

projectImage

单色串并联电路

 

projectImage

Simplified prefboard design

projectImage

Code

Simple lightshow

C/C++

CODE
// LED PINS (n € N)
//  green: 2n+1, n<5
//  red: 2n+2, n<5
//  yellow: n+11, n<3

#define SHORT unsigned short

void setup() {
  
  for(SHORT pin=1; pin<14; pin++) 
    pinMode(pin, OUTPUT);
}

void clearLeds() {
    
  for(SHORT pin=1; pin<14; pin++)
    digitalWrite(pin, LOW);
}

void firstProgramme() {
  
  for(SHORT pin=1; pin<14; pin++)
    digitalWrite(pin, HIGH);

  delay(3000);

  clearLeds();
}

void secondProgramme() {

  delay(700);

  for(SHORT n=0; n<5; n++) {
    
    digitalWrite(2*n+1, HIGH);
    digitalWrite(2*n+2, HIGH);
    
    delay(700);
  }

  for(SHORT pin=11; pin<14; pin++)
    digitalWrite(pin, HIGH);

  delay(700);

  for(SHORT i=0; i<6; i++)
    for(SHORT n=13; n>10; n--) {
      
      for(SHORT pin=11; pin<14; pin++)
         digitalWrite(pin, pin == n);

      delay(100);
    }

 digitalWrite(11, LOW);

  for(SHORT pin=13; pin>10; pin--) {
    digitalWrite(pin, HIGH);
    delay(100);
  }

  clearLeds();
}

void thirdProgramme() {

  SHORT counter = 0;
  
  for(SHORT pin=11; pin<14; pin++)
    digitalWrite(pin, HIGH);

  while(counter<31) {
    
    for(SHORT pin=1; pin<11; pin++)
      digitalWrite(pin, (pin + counter)%2);

    delay(300);
    counter++;
  }

  clearLeds();
}

void loop() {

  firstProgramme();
  secondProgramme();
  thirdProgramme();
   
}

The article was first published in hackster, January 5, 2020

cr: https://www.hackster.io/henyte/christmas-led-tree-decoration-064a38

author: henyte

License
All Rights
Reserved
licensBg
3