Christmas Tree with Arduino

Introduction

In this project we will see how to do a blinking Christmas tree with leds and an Arduino card. This decoration will be a good idea to decor your house during christmas.

Difficulty

Necessary equipment

Necessary equipment to realize the project:

  • An Arduino card
  • 1 yellow led (for the stars)
  • 7 red leds
  • 5 green leds
  • 6 resistors 220 ohms

Project scheme

What are resistors useful for?

The resistors are used to reduce the current in the leds. These protects your leds from burning out. To calculate the value of the resistor you need you can read our course about it.

How to make the structure of your christmas tree?

To make the structure of your christmas tree, you can use cardboard cut shaped as a christmas tree and glue the leds. The cardboard gives a wood effect to your christmas tree. You can also make the structure with a 3d printer in a brown color to reproduce the wood effect.

Project Program

int led_Red_top = 12;  // We assign the top red leds at the pin 12 
int led_Red_bottom = 11;  // We assign the bottom red led at the pin 11 
int led_Green = 10; // We assign the green leds at the pin 10
int led_Yellow = 7; // We assign the yellow leds at the pin 7

void setup() {
  // We assign all the leds as an output of the Arduino card
    pinMode(led_Red_top, OUTPUT); 
   pinMode(led_Red_bottom, OUTPUT); 
   pinMode(led_Green, OUTPUT); 
    pinMode(led_Yellow, OUTPUT); 
  
}

void loop() {
  
digitalWrite(led_Red_top,HIGH); // We turn on the led 
digitalWrite(led_Red_bottom,HIGH); // We turn on the led 
digitalWrite(led_Green,HIGH); // We turn on the led 
digitalWrite(led_Yellow,HIGH); // We turn on the led 
  
 // We blink the leds  
delay(1500);
digitalWrite(led_Red_bottom,LOW); //We turn off the red leds 
digitalWrite(led_Red_top,LOW); // We turn off the red leds 
delay(1000);
digitalWrite(led_Green,LOW); //We turn off the green leds 
digitalWrite(led_Red_top,HIGH); // We turn on the red leds 
digitalWrite(led_Red_bottom,HIGH); // We turn on the red leds 
delay(1000);
digitalWrite(led_Green,HIGH); // We turn off the green leds 
  
}

How to upload the program into the Arduino card?

To do that you will need Arduino ide software. You juste have to copy the program above into arduino ide and the software will upload the program for you.

Modify the program

The program that we realized blink the leds at 1 second with different colors. You can change the delay to blink quicker or slower the leds.

Project simulation

Here is the project simulation on tinkercad: