Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
henyte
Published © GPL3+

Christmas LED Tree Decoration

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

IntermediateShowcase (no instructions)7,761
Christmas LED Tree Decoration

Things used in this project

Hardware components

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

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Drill / Driver, Cordless
Drill / Driver, Cordless
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

SIngle color series circuit

SIngle color series-parallel circuit

Simplified prefboard design

Code

Simple lightshow

C/C++
// 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();
   
}

Credits

henyte

henyte

0 projects • 1 follower

Comments