Introduction

In this project, we’ll show you how to make an electric Christmas garland for your Christmas tree. We’ll see how to make it flash, how to change the colors on each LED to make your Christmas tree shine!

We’ve also included a project to make your own Christmas tree!

Difficulty:

Materials required

We will now list the hardware required for the project:

Be careful with electricity and your tree!

In this course, we’re going to mix electricity with a Christmas tree. When soldering, for example, you’ll need to be very careful to protect it with heat-shrink tubing.

Arduino Factory declines all responsibility in the event of an accident!

Schematic diagram

Do you need an external power supply?

The led ribbon we use requires a lot of power. Above a certain number of leds, you’ll need an external power supply to operate the led ribbon.

To connect your external power supply, you can remove the two red and black wires and replace them with the external power supply.

Project program

#include <Adafruit_NeoPixel.h> // Library used
int PIN = 2; // Led strip pin
int numPixel = 4; //number of LEDs containing ribbon
// We declare the library with the previous data
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(numPixel,PIN, NEO_GRB + NEO_KHZ800); 
void setup() {
	pixels.begin(); //Initialize the library
}

void loop(){
  pixels.clear(); //Turn off the LEDs
  pixels.setPixelColor(0, pixels.Color(0,0,255)); // We assign the color blue to the led
  pixels.setPixelColor(1, pixels.Color(0,255,0)); // We assign the color green
  pixels.setPixelColor(2, pixels.Color(255,0,0)); // We assign the color red
  pixels.setPixelColor(3, pixels.Color(0,0,255)); // We assign the color blue
  pixels.show(); //We light the led with the color
  delay(1500);
  pixels.clear(); 
  //We make the leds blink by turning everything white
  pixels.setPixelColor(0, pixels.Color(0,0,0)); // We assign the color white to the led
  pixels.setPixelColor(1, pixels.Color(0,0,0)); // We assign the color white 
  pixels.setPixelColor(2, pixels.Color(0,0,0)); // We assign the color white
  pixels.setPixelColor(3, pixels.Color(0,0,0)); // We assign the color white
  pixels.show(); //We light the led with the color
  delay(1500);
  
      }

Change ribbon size

As you can see in program line 3, this is suitable for a 4-LED strip (counting 0).

If you have a led strip with more or less 4 leds, you’ll need to change this number to the one corresponding to the number of leds minus 1:

int numPixel = 4; //number of LEDs containing ribbon

Change ribbon color and blinking

You may want to change the color and flashing speed of the ribbon.

To change the color of a led, simply select one of the lines between 12 and 15, depending on the led you wish to change. The led number appears just after the word Color. To change the color of the led, you have the three digits 0,0,255. This corresponds to blue:

pixels.setPixelColor(0, pixels.Color(0,0,255)); 

To make the leds flash more or less quickly, you can modify the “delays” on lines 25 and 17. For information, the pause is calculated in milliseconds, so 1500 ms corresponds to 1.5 seconds.

How do I get the program onto the Arduino board?

To put the program on the Arduino board, you’ll need the Arduino IDE software. Once on the software, choose the port where your board is located and upload your program. You’ll need to have downloaded the library used for the led ribbons

How to install the led ribbon library?

To operate the led ribbon, you’ll need the Adafruit library. You can download it from their github.

To install it, take a look at our course on libraries.

Project simulation

Let’s see the project simulation on tinkercad :

Conclusion

Once you’ve finished the project, all you have to do is wrap the garland around your Christmas tree. Don’t forget to protect the welds!