YACTL: Another Christmas tree garland

    Why?


    Before the New Year, many dress up and decorate the Christmas trees with all kinds of trinket toys and, of course, with a light garland.
    On Habré there have recently been several variations on the theme of home-made garlands, but there are less than 100,500 and therefore I thought that this was clearly not enough. In order not to anger the spirit of the New Year, I bring my own version of the Christmas garland as a gift to this great spirit.

    Also, this project was conceived as part of the initial education for his son in the style of "I do and tell what, how and why, and the son looks and asks tricky questions on the topic and not really." For this reason, I tried to make everything as simple and affordable as possible.





    Of what?


    Having rummaged a bit in my boxes, I found several tapes of individually addressable RGB LEDs. In the wild, they have different names - WS2801, WS2811, WS2812, Neopixels, etc.
    The main highlight of these tapes is that you can control any RGB LED individually and change the RGB color components and brightness.

    The differences between the tapes are electric. If very rude, then they can be described like this:
    WS2801 is the very first version. Data is transmitted through two signal wires - DATA and CLOCK. Power is usually 12 volts. RGB LED is connected separately.
    WS2811- newer version. Data is transmitted on one wire - DATA. There is no CLOCK signal, since the WS2811 controller itself calculates the time intervals and must be followed in its code. Usually powered by 5 volts. The RGB LED is also connected separately.
    The WS2812 is the same as the WS2811, but it is integrated in the LED (for example, 5050), which makes the tape more compact and with a more dense placement of the LEDs. Usually powered by 5 volts. The LED chip has 6 pins.
    WS2812B - like WS2812, but with the difference that the power for the LEDs and the chip itself is combined (all options have separate power supply). The LED chip has 4 pins.

    Any variations of LED strips can be bought on eBay, Alibaba / AliExpress and in stores of this type.

    From a programming point of view, the difference is very nicely smoothed using the FastLED @ GitHub library . That is, it is possible to combine different types of programmable tapes in one project without much hassle, which I used without embarrassment. The son, however, did not appreciate his father's resourcefulness and convenience of the library.

    I found three tapes at home: one based on the WS2801 controller (25 LEDs) and two based on the WS2811 controller (20 and 15 LEDs). A total of 60 LEDs puppy joy.
    Two WS2811 I connected together in series.

    As the reader’s inquiring mind already guessed, a controller is needed to control such LED strips. Initially, I planned to use the Arduino Pro Mini board because of its compactness and readiness, but for some reason I did not find a single one in my bottomless bins. But I found Teensy 3.1 (Cortex-M4 @ 72MHz, 256KB Flash, 64KB RAM). It’s a bit overkill, but a lot is better than a little.

    Since I use 12 and 5 volt tapes together, I fed the entire circuit from a 12V / 1A power supply with 5 volt conversion to power the second tape and microcontroller board. I converted using a pulsed DC-DC module KIS-3R33S based on MP2307DN, which gives up to 3A output and almost does not heat up. Of course, the module can be replaced with something like 7805, but it will be necessary to take care of proper cooling (this is about 1-1.5 watts for every 10 LEDs).



    Component List:


    • Individually addressable LED strips based on WS2801, WS2811, etc.
    • 12V / 1A power supply. At maximum brightness, 60 LEDs consumed approximately 800 mA. I turn them on half-brightness and get 400 mA consumption
    • Microcontroller module Teensy 3.1. Arduino or another suitable module or microcontroller is also suitable.
    • DC-DC converter KIS-3R33S. There are many options and it all depends on the nutrition requirements.




    How to connect?


    There is practically no circuit, since everything is connected quite simply:
    Teensy 3.1 is powered by 5 volts. At these 5 volts sits the WS2811 tape. At 12 volts there is a tape based on WS2801.
    The WS2801 tape is connected to Teensy 3.1 as follows: DATA - 11, CLOCK - 13. The
    WS2811 tape is connected to Teensy 3.1 commercials: DATA - 14. A



    bundle of wires and parts was successfully stuffed into a box to store four AA elements. I usually collect something so simple and fast in such boxes.



    What is the magic?


    The magic is in the code that governs all this disgrace and delights the three-year-old son.
    I posted my code on GitHub: github.com/nochkin/LightBottle (you need the github.com/FastLED/FastLED library )
    Everything is quite simple in the code - a color is pseudo-randomly selected into which the LED smoothly transitions and the current color moves further along the LED ribbon. On the tree it looks as if the light is falling down. Or upstairs if, for example, you turn the tree over (son’s advice) or hang the ribbons themselves on the contrary (my irrational offer).

    At the very beginning of the code, I derived some variables for the configuration:
    LEDS1_NUM / LEDS1_PIN - the number of LEDs and the pin for connecting the first tape
    LEDS2_NUM / LEDS2_PIN - number of LEDs and pin for connecting the second tape
    LEDS_SATURATION - maximum color saturation
    LEDS_BRIGHTNESS - maximum brightness (at 60 LEDs, approximate consumption was 800 mA at a brightness of 255, 400 mA at 128 and 200 mA at 64)
    hueStep - color change step in one cycle
    UPDATE_DELAY - speed of “running” the colors on the tape

    In setup () both tapes are configured, so if there is only one tape, you can leave only one line that corresponds to the tape controller and reset LEDS2_NUM.

    And the cartoon?


    I am attaching a video of this craft. I apologize for the telephone quality and portrait orientation.


    I also want to convey congratulations on coming to all Khabrovites. Cheers cheers!


    Also popular now: