Easy LED Holiday Light Show: Wizards in Winter | WS2812B LED Strip With FastLED and an Arduino Tutorial

by Zero To Infinity in Circuits > Electronics

6164 Views, 10 Favorites, 0 Comments

Easy LED Holiday Light Show: Wizards in Winter | WS2812B LED Strip With FastLED and an Arduino Tutorial

maxresdefault.jpeg
Christmas Light Show: Wizards In Winter

I designed and programmed this holiday light show to display anywhere. I used one WS2812B led strip with a pixel density of 30 pixels/ meter. Since I used 5 meters, I had a total of 150 LEDs. I kept the code simple so that anyone new to using WS2812B LED strips could easily follow the code. This also means that if you use different amounts of pixels, the timing will be off, so you should stick to 150 LEDs. Also, keeping it simple, the music system is not managed by the Arduino at all. At the beginning of the program, there are 3 flashes of green and 1 flash of red, then the actual light show starts. Since you have to start the music manually, these initial flashes are to give you an indication of when to start playing the music. I have included the code below. Feel free to add on to or change this code for non-commercial purposes.

Supplies

- WS2812B LED Strip

- Arduino

- Wires

- 5V 10A Power Supply | If you are using more than one strip, you will need to use a larger power supply. Each pixel uses 60mA, so 150 pixels * 60mA = 9A. Your power supply must be able to handle this if you intend to use full brightness at white. You must use a 5V power supply if you are using 5V LED strips and if you are using 12V LED strips, you will need to use a 12V power supply, but also use a 12-5V converter to power the 5V Arduino.

Download the FastLED Library

Screen Shot 2020-01-25 at 1.28.00 PM.png

If you don't already have the FastLED library downloaded, download the latest version from github.com/FastLED/FastLED/releases

Download the FastLED library, and move it to your Arduino libraries folder. Do NOT change the name of this folder. In the Arduino IDE, go to Sketch, Include Library, and then Add .ZIP Library. Select the FastLED folder.

Once your library is set up, include the line #include This line tells the program that you are using that library.

Define a Few Variables

Screen Shot 2020-01-25 at 1.00.52 PM.png

As I mentioned earlier, in order to keep the code simple, changing the number of pixels will change the timing or the light show.

The line #define NUM_LEDS 150 is where you put the number of pixels used. In this case, it will be 150.

The line #define DATA_PIN 5 is where you put the digital pin that you connected the data wire to.

The line #define BRIGHTNESS 255 is where you put the brightness from a scale of 0-255, with 255 being the brightest.

The Setup Section of Code

Screen Shot 2020-01-25 at 1.01.54 PM.png

In the setup section, there is a delay for 2 seconds and the line

FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

WS2812B indicated the type of LED strip that we used and DATA_PIN is the variable that we defined in a previous step. GRB is the color order. This could vary depending on the LED strip used. Try the code as is, and if the colors aren't the same as in the video, try changing this to RGB, or BRG for example. You can leave the rest of this line the same. The lines

FastLED.setBrightness(max_bright);
set_max_power_in_volts_and_milliamps(5, 8000);

limit the power usage of the LED strip. This is an amazing feature from the FastLED library. The number 5 is the voltage that we used, and the number 8000 is the maximum current that the LED strip can use in mA. It is recommended to only use 80% of the power supply's capability to extend its lifetime. Since I have a 10A power supply, 0.8*10 = 8A, or 8000mA.

The Loop Section | Aka, the Cool Part of the Code

Screen Shot 2020-01-25 at 1.02.16 PM.png
Screen Shot 2020-01-25 at 1.02.46 PM.png

Now that we are done setting up the program for our particular LED strip, we can get to part the actually makes the strips light up. To keep this section looking clean, I used wrote functions to control the strips and do different effects. The above picture to the left is part of the loop section, which runs the functions. The picture on the right is below that and is where I wrote what each function does.

Wiring

Screen Shot 2020-01-25 at 2.16.29 PM.png

The WS2812B LED strips have 3 terminals at each end. 2 for power, and 1 for the data signal coming from our Arduino. Simply connect 2 wires to the Arduino's power terminals, and connect 2 power wires to the LED strip. You should also add 2 power wires called power injection wires to the end of the strip because voltage loss can lead to dim LEDs at the end of the strip if you don't do this. Check the labels on the strip to see which terminal is for what. Mixing up the polarity could lead to a fried strip. Also, connect the Arduino's ground wire to the ground wire on the LED strip to establish a common ground for better data transmission. I mentioned that you should add power injection wires, but you CAN NOT do this for the data wire. This is because each LED rebroadcasts the data signal to the next one, so make sure to connect 1 data wire to the specified Arduino pin and the LED strip. The strip should have a small arrow indicated the direction of data travel. Make sure the put the data signal wire at the beginning and not the end. Mixing this up could lead to a fried strip.

Mounting the LED Strip

I mounted my LED strip to the inside of a window by simply taping it. However, there are many other ways that you could mount your LED strip. You could use an aluminum channel such as https://tinyurl.com/s2km4v3 to put the strips outside on your roofline. If you are putting your LED strips outside, I recommend using the ip65 strips if you are using an aluminum channel because they are semi-waterproof, and are thinner than the 1p67, which may not fit in some channels. If you intend to mount this outside without a channel, use the ip67 strips, which are practically waterproof. To go around a corner, such as the ones at the peaks of your roofline, you should ideally cut the strip, and use wires to go around the corner. You may be able to away with just bending the strip, but be wary of how much you bend them because it's easy to pop off an LED.