LED strip
Overview
This sample application demonstrates basic usage of the LED strip.
Requirements
Zephyr supports various LED strip chips. For example,
WS2812, such as the NeoPixel(WS2812 compatible) LED Strip from AdaFruit.
APA102, such as the Dotstar(APA102 compatible) LED Strip from AdaFruit.
LPD8806, such as the LPD8806 LED Strip from AdaFruit.
Power supply. These LED strips usually require a 5V supply.
If the LED strip connects to the SPI bus, SPI communications usually use 5V signaling, which may require a level translator, such as the 74AHCT125 datasheet.
Wiring
APA020 and LPD880x
Ensure your Zephyr board, the 5V power supply, and the LED strip share a common ground.
Connect the MOSI pin of your board’s SPI master to the data input pin of the first IC in the strip.
Connect the SCLK pin of your board’s SPI master to the clock input pin of the first IC in the strip.
Connect the 5V power supply pin to the 5V input of the LED strip.
WS2812
Ensure your Zephyr board, and the LED strip share a common ground.
Connect the LED strip control pin (either I2S SDOUT, SPI MOSI or GPIO) from your board to the data input pin of the first WS2812 IC in the strip.
Power the LED strip at an I/O level compatible with the control pin signals.
Note about thingy52
The thingy52 has integrated NMOS transistors, that can be used instead of a level shifter.
The I2S driver supports inverting the output to suit this scheme, using the out-active-low
dts
property. See the overlay file
samples/drivers/led/led_strip/boards/thingy52_nrf52832.overlay for more detail.
Building and Running
The sample updates the LED strip periodically. The update frequency can be
modified by changing the CONFIG_SAMPLE_LED_UPDATE_DELAY
.
Then build and flash the application:
west build -b <board> samples/drivers/led/led_strip
west flash
When you connect to your board’s serial console, you should see the following output:
***** Booting Zephyr OS build v2.1.0-rc1-191-gd2466cdaf045 *****
[00:00:00.005,920] <inf> main: Found LED strip device WS2812
[00:00:00.005,950] <inf> main: Displaying pattern on strip