WS2812 addressable LEDs test

RGB LEDs are awesome – especially the new, fancy ones with the WS2812 RGB LED driver. These LEDs can be individually controlled to display red, green, and blue, but interfacing them with a microcontroller or computer.

To test controlling WS2812 RGB LEDs I bought a cheap addressable LED strip. An addressable RGB LED strip is a long flexible strand of LEDs each of which can be individually set to a certain color (hence: addressable). By varying the level of red, green and blue (RGB) per LED many color combinations can be made. Addressable LED promise is to be an easy way to add complex lighting effects to any project. WS2812 neopixels are addressable RGB LEDs. The integrated controller chip allows you to change the color of the LED and address each individual LED. ThoseWS2812 LEDs are powered with 5V – 7V power source (60 mA power consumption) and are controlled through a serial bus (one control signal).

I planned to use either Arduino or ESP8266 to control those LEDs. After some looking on vailable examples and technical data on the LEDs, I planned to use Arduino (Arduno Uno), because it’s 5V power and 5V logic level is directly suitable. And there are many Arduino tutorials for WS2812.

To get easy start, I planned to follow instructions fro Arduino Addressable LEDs & Splendid Projects page. That page had an example source code that looked to be useful and simple wiring instructions.

In the first test I fould out that in addition to the source code I also needed NeoPixel Arduno library. So I needed to get the library from https://github.com/adafruit/Adafruit_NeoPixel and install it according to instructions. After downloading, I had to rename folder to ‘Adafruit_NeoPixel’ and move it to Arduino Libraries folder. After restarting Arduino IDE , I opened File->Sketchbook->Library->Adafruit_NeoPixel->strandtest sketch example file.  This worked well. I also tried the original code fromArduino Addressable LEDs & Splendid Projects page which I modified to use 8 LEDs instead of one. Both examples made a “random” color light show on my LED strip. Enough for first testing.

image

 

image

image

133 Comments

  1. Tomi Engdahl says:

    How to use WS2812B RGB LEDs with Arduino
    https://www.youtube.com/watch?v=9hJyyUTflXA

    This tutorial is aimed at getting some instant gratification from your WS2812 LEDs (trade name: NeoPixels). I’ll briefly cover a bare-bones setup for Arduino.

    The full tutorial for this video (with images and step-by-step tips)

    WS2812 Addressable LEDs: Arduino Quickstart Guide
    https://core-electronics.com.au/tutorials/ws2812-addressable-leds-arduino-quickstart-guide.html

    Reply
  2. Tomi Engdahl says:

    The BEST Digital LED Strip Light Tutorial – DIY, WIFI-Controllable via ESP, MQTT, and Home Assistant
    https://www.youtube.com/watch?v=9KI36GTgwuQ

    Today, I’m bringing you a video of one of my favorite things – digital LED strips! These LED strips are everywhere these days, but getting started with them can seem daunting and I want to change that. In this video, I’ll be covering the basics on how to choose the right strip, strategies for mounting and powering them, how to control the strip(s) using a NodeMCU chip, and of course, how to automate your home with them.

    Reply
  3. Tomi Engdahl says:

    Home automation over WiFi using WeMos ESP8266
    https://www.youtube.com/watch?v=7Dv70ci-MOw

    This video shows how to use a smartphone to controll LED ligths.
    It also supports controlling switches.

    https://github.com/bitluni/bitluniHomeAutomation

    Reply
  4. Tomi Engdahl says:

    How to control WS2812B RGB LEDs with FastLED and Arduino
    https://www.youtube.com/watch?v=EcMKditEVtY

    Schematics and Arduino sketch download as .zip file: http://hamburgtech.de/downloads/
    FastLED Video Tutorial Code

    Reply
  5. Tomi Engdahl says:

    LED-ifying A Guitar, Part Two
    https://hackaday.com/2018/11/23/led-ifying-a-guitar-part-two/

    An electric guitar is all about stage presence. Need to be cooler than a single guitar? No problem — there are double neck guitars. Need to be cooler than that? No problem, the guy from Cheap Trick has a five-neck guitar. Need to be cooler than that? Robbie Robertson played a guitar with an extra mandolin neck on The Last Waltz. Where do you go from there? Obviously, the solution is putting a TV in your guitar with a boatload of individually addressable LEDs in a guitar. That’s what [Englandsaurus] is doing, and the build thread is now getting into how to turn a bunch of LEDs into a display.

    https://www.sparkfun.com/news/2822?utm_content=79997213

    The next logical step was to combine these two ideas and make a DMX-controlled, glowing guitar! Also, if you’d like to get more familiar, check out my tutorial on DMX below.

    DMX512 is an industry standard in lighting and stage design, whether it be controlling lights, motors, or lasers, DMX512 has many uses.

    The issue here is that DMX is a fire and forget protocol, meaning that it never checks to see if a message is actually received (this is why you shouldn’t control pyrotechnics or stage architecture with DMX). Due to this, DMX packets are occasionally dropped.

    Reply
  6. Tomi Engdahl says:

    Using Artnet DMX and the ESP32 to Drive Pixels
    https://learn.sparkfun.com/tutorials/using-artnet-dmx-and-the-esp32-to-drive-pixels?

    Creating an ArtNet Node on the ESP32

    We now have to get our ESP32 to listen for DMX data on the WiFi network. In order to do this, we’ll first need to setup the ESP32 Core on the Arduino IDE.

    Reply
  7. Tomi Engdahl says:

    12 Tips and Tricks for Neopixels Projects (Arduino, ESP8266/ ESP32)
    https://www.youtube.com/watch?v=IIl5nDjfkjY

    I love Neopixels, and I think they are a real invention. And they are dirt cheap. But you have to pay attention if you plan to use them! You can even burn your house.

    Comments:

    Tip #13: add a small and cheap 24 to 5V buck converter (less than 1$ for a 2A one) to each set of n neopixels, and use a 19v laptop power supply to feed the lot. I did this to avoid voltage drop and the ability to use much thinner wires.

    Having recently designed an LED system to go into an SUV for a ridesharing company, can confirm this is the way to go.

    Tip #14: find neopixels based on the WS6812. These are easier to drive, and exist in RGBW (cold or warm white) when you want more purer white or nicer pastel colors. The disadvantage is that when only blue is on also makes the phosfor in the white part glow a bit, so the blue will be less pure.

    Connect the first +5V/GND (in) and the last +5V/GND(out) the your power supply, to fix the problem with different brightnesses. AND you don’t have the full current on one cable pair.

    Reply
  8. Tomi Engdahl says:

    How to Make RGB Scrolling Text Display Using NeoPixel Matrix
    https://www.youtube.com/watch?v=QIijJGk0uCk

    Reply
  9. Tomi Engdahl says:

    Build Festive Lighting for the Holidays with balena
    https://www.hackster.io/chriscw/build-festive-lighting-for-the-holidays-with-balena-899f0e

    Set up some programmable festive tree lighting with Raspberry Pi, Fadecandy and Glediator software driving addressable RGB LED pixels.

    There’re a few things you’re going to need to build this project:

    Some addressable 5V RGB LEDs
    Raspberry Pi 3 & SD Card
    A free balenaCloud account
    Fadecandy board
    High quality power supply (i.e. Mean Well LRS-100-5)
    Case to put everything in (or 3D printer to print one)

    Reply
  10. Tomi Engdahl says:

    Homemade Daft Punk Helmet
    https://hackaday.com/2018/12/29/homemade-daft-punk-helmet/

    You may not be French, and you may not have had a series of hit records, but you can still have the blinky LED helmet, thanks to this build from [Electronoobs]. They have put together a neat Daft Punk helmet built from 3D printed parts, an Arduino, a Bluetooth module, a string of WS2812 addressable LEDs and a simple app. The helmet itself is 3D printed, and the Arduino, Bluetooth, and battery are mounted in the chin. The LED panel is a series of WS2812 LED light strips wired together in series. The whole thing is controlled over a Bluetooth connection to an Android app that was built with the MIT App Inventor.

    Daft Punk Helmet Bluetooth RGB strip
    https://www.electronoobs.com/eng_arduino_tut62.php

    Reply
  11. Tomi Engdahl says:

    Glue Sticks Turned into Brilliant “Fiber Optic” Display
    https://blog.hackster.io/glue-sticks-turned-into-brilliant-fiber-optic-display-70bae0cb065b

    An Arduino Nano powers 128 WS2811 LED modules that produce this light, and because of the way these amazing devices work, control is accomplished with only two digital outputs — and could be reduced to one in a pinch.

    Reply
  12. Tomi Engdahl says:

    Dave Lights Up His Garage with ESP32s and 16,000 RGB LEDs
    https://blog.hackster.io/dave-lights-up-his-garage-with-esp32s-and-16-000-rgb-leds-36312e7237fe

    Dave’s massive garage has been absolutely crammed full of LEDs. Those appear to be generic WS2812B individually-addressable RGB LEDs — what most people refer to by Adafruit’s “NeoPixel” brand name. But, powering and controlling 16,000 animated RGB LEDs is no small feat, which is why Dave turned to the humble ESP32.

    Reply
  13. Tomi Engdahl says:

    Interesting idea but considering that there are around 100 LEDs that look like WS2812 or similar. 100 ws2812 LEDs would need to have 6A 5V power supply to to support full brightness. Thin wires, hundreds of small soldering joints and consuderable currents next to flammable ping pong ball material does not feel very safe design.

    Iridescent LED Clock Made with Ping Pong Balls
    https://blog.hackster.io/iridescent-led-clock-made-with-ping-pong-balls-ed478595c5a1

    Reply
  14. Tomi Engdahl says:

    Use WS2812B Make a Suit that Light Up
    https://create.arduino.cc/projecthub/kuongshunelectronic/use-ws2812b-make-a-suit-that-light-up-2620d4

    Use the WS2812B SMD LED Strip to sew on clothes. The control board uses Arduino UNO R3 and Mega 2560.

    Reply
  15. Tomi Engdahl says:

    Inefficient NeoPixel Control Solved with Hardware Hackery
    https://hackaday.com/2019/02/18/inefficient-neopixel-control-solved-with-hardware-hackery/

    Everyone loves NeoPixels. Individually addressable RGB LEDs at a low price. Just attach an Arduino, load the demo code, and enjoy your blinking lights.

    But it turns out that demo code isn’t very efficient. [Ben Heck] practically did a spit take when he discovered that the ESP32 sample code for NeoPixels used a uint32 to store each bit of data. This meant 96 bytes of RAM were required for each LED. With 4k of RAM, you can control 42 LEDs. That’s the same amount of RAM that the Apollo Guidance Computer needed to get to the moon!

    His adventure is based on the thought that you should be able to generate these signals with hardware SPI. First, he takes a look at Adafruit’s DMA-Driven NeoPixel example.

    [Ben]’s solution uses some external hardware to reduce software requirements. The 74HC123 dual multi-vibrator is used to generate the two pulse lengths needed for the NeoPixels. The timing for each multi-vibrator is set by an external resistor and capacitor, which are chosen to meet the NeoPixel timing specifications.

    The 74HC123s are clocked by the SPI clock signal, and the SPI data is fed into an AND gate with the long pulse

    https://github.com/benheck/SPI-Neopixel

    Reply
  16. Tomi Engdahl says:

    Low cost LED Panel
    https://hackaday.io/project/162951-low-cost-led-panel

    The aim of this project is to have a low cost led panel assembled

    I am using Jinx and an Arduino Uno board to drive the LED Panel.
    Next step will be to drive the panel using an ESP32 DEV KIT board and have a 50cm x 25cm LED Panel with a better resolution (30×17 leds).

    Reply
  17. Tomi Engdahl says:

    Can You Live Without the WS2812?
    https://hackaday.com/2019/03/26/can-you-live-without-the-ws2812/

    As near as we can tell, the popular WS2812 individually addressable RGB LED was released to the world sometime around the last half of 2013. This wasn’t long ago, or maybe it was an eternity; the ESP8266, the WiFi microcontroller we all know and love was only released a year or so later. If you call these things “Neopixels”, there’s a good reason: Adafruit introduced the WS28212 to the maker community, with no small effort expended on software support, and branding.

    The WS2812 is produced by WorldSemi, who made a name for themselves earlier with LED driver solutions, especially the WS2811, an SOIC chip that would turn a common anode RGB LED into one that’s serially controllable. When they stuffed the brains from the WS2811 into a small package with a few LEDs, they created what is probably the most common programmable LED lighting solution available today.

    A lot has changed in the six years that the WS2812 has been on the market.

    While the WS2812B, 2813, and associated LEDs are great for adding blinky, there’s only so much you can do with a large, 5 mm x 5 mm square package.

    WS2815

    While the WS2812 plays well with five volts, ohm’s law is a thing and RGB LEDs draw a lot of current. It would be nice if there were an individually addressable RGB LED that worked with higher voltages. It’s like how electric kettles aren’t a thing with 120 V mains power. Sometimes more voltage is better.

    Enter the WS2815. Running at 12 V decreases the current, decreases resistive losses, and if you’re running really long strands of LEDs, makes mixing LED colors more consistent.

    APA-109B

    there are other manufacturers of serially addressable LEDs, and some of these chips have some interesting features.

    If you want to create a display with a wide color gamut, you need to make a display with four colors: red, green, blue, and what’s best described as ’emerald’. The emerald is deeper, and not as ‘neon’ as a traditional green sub-pixel on an LCD TV.

    An executive at Sharp ran with the idea until a marketer stepped in and said that nobody can sell two greens. What would you call it, “other green”.
    The APA-109B is the solution to trying to display white with red, green, and blue LEDs.

    Reply
  18. Tomi Engdahl says:

    Lots of Blinky! ESP32 Drives 20,000 WS2812 LEDs
    https://hackaday.com/2019/05/07/lots-of-blinky-esp32-drives-20000-ws2812-leds/

    To be fair, we’re not sure that [yves-bazin] has put together 20,000 LEDs yet, but he HAS demonstrated the feasibility of driving 20k LEDs all at once thanks to some editing of the FastLED I2S library and hardware GPIO expansion. The trick is in using a shift register to convert a single ESP32 pin into five outputs.

    https://old.reddit.com/r/esp32/comments/bkyeq0/20000_ws2812b_pushed_at_130fps_with_esp32_and/

    Reply
  19. Tomi Engdahl says:

    DIY LED Video Wall made in 24 hours
    https://www.youtube.com/watch?v=fz2QAV9z_o8

    This is how I made an LED video wall within 24h. It’s based on WS2812 controlled RGB LEDs and supported by a wide range of Arduino libraries. Enjoy!

    Reply
  20. Tomi Engdahl says:

    Rust, a Raspberry Pi and Addressable LED’s
    https://blog.tomarrell.com/post/rust_and_leds

    The WS2812b runs a protocol that can nicely be mapped to Pulse Width Modulated (PWM) peaks with a frequency of 800,000Hz or 800KHz. We’re able to encode a 1 using a duty cycle of approximately 66%, and a 0 with a duty cycle of approximately 33%.

    we need to send a buffer of 24 bits which is consumed by the next pixel in line. The 24 bits encode the red, green and blue hues for the consuming pixel. Once a pixel has consumed a buffer, it will forward any further bits along the chain until it receives a reset signal, where it will display its resulting hue.

    The Raspberry Pi does have built in hardware PWM. However, I wanted to make it a little more difficult than simply relying on hardware implementation. So bit-banging it was.

    Experimenting with bit banging on the Raspberry Pi to the WS2812b’s made things pretty evident. Trying to bit bang from user space on top of the Linux Kernel, even without a garbage collector in your binary, is just not very feasible.

    So with raw bit banging a digital pin off the table, I had a look at another relatively simple serial protocol (…interface), SPI. SPI

    we can approximate the highs and lows to some multiple of 1/3.

    This means that if we run a MOSI SPI signal at triple the frequency the lights expect, then we can send a single WS2812b “panel bit” using a combination of 3 SPI bits.

    This would give us rough timings of 416.67ns per SPI bit, and overall 1.25us for the entire panel bit.

    The LED’s run with a scan frequency of no less than 400Hz, with a data transfer rate of 800kbps.

    Implementation
    The very unpolished code to make this work is surprisingly minimal, thanks to the fantastic library rppal, written by @golemparts. It allows for controlling the Raspberry Pi’s SPI ports using the Linux Kernel’s SPI device interface from Rust.

    Reply
  21. Tomi Engdahl says:

    sorry to hear about the passing of Daniel Garcia, the originator of FastLED.
    Dan’s legacy will live on in countless colorful Arduino projects…

    http://fastled.io/

    FastLED is a fast, efficient, easy-to-use Arduino library for programming addressable LED strips and pixels such as WS2810, WS2811, LPD8806, Neopixel and more. FastLED is used by thousands of developers, in countless art and hobby projects, and in numerous commercial products.

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *

*

*