Christmas lights

The goal of this tutorial to build an ESP8266 controlled Christmas light strip with a special effect that usually can’t be found in standard LED controllers.

Ingredients

  • LED strip: in this tutorial we are using a WS2815 LED strip, at the same time any FastLED compatible strip will work
  • LED power supply: the WS2815 strip needs a 12V power supply, other LED strips might need a 5V supply
  • Wemos D1 mini: the code here was tested on an ESP8266, at the same time it is not using any HW specific library thus any controller which is compatible with the FastLED library will work fine
  • KEECO breakout panel: this is not a must at the same time can tidy up the cabling to the Wemos D1 mini. You can download the PCB design from here.
KEECO Breakout Panel for the LED Strip connection

Code

The code is using the FastLED library so you need to install it first.

Interfacing with the LED strip via the FastLED library works in a way that you assign RGB (or HSV) values to each LED and this information is stored in an array. After you have assigned the right values you call a function to update the LEDs and now the new values can be visible.

The application for the Christmas lights can be downloaded here. The theory of operation is that we maintain an array of “light pulses” that has random:

  • Hue
  • Brightness
  • Length
  • Speed

Each light pulse starts its life on the beginning of the LED strip, travels at the randomly defined speed and then ends its life when gets to the end of the strip. This means that light pulses can overlap and take over each other. I think this is the really unique feature of this application.

You can set the following variables:

//LED_pulsar.ino
#define NUM_LEDS 300          //Number of LEDs in the strip, min 12 pcs
#define DATA_PIN 5            //Data pin on the controller
#define CLOCK_PIN 13          //Not needed for WS2815
//#define DEBUG               //To see a representation of the pulses in the Serial Monitor (ruins performance)

//pulse.h
#define PULSE_NO 15           //maximum number of simultaneous light pulses
#define LED_RATE 3            //LED update rate

The other unique feature of this application is that we use a simple pipelining to improve performance. We are using non-blocking waits to make sure that while we are not updating the LEDs we can calculate the new values.

Result

Leave a Reply