LED strip

Overview

This sample application demonstrates basic usage of the LED strip.

Requirements

Zephyr supports various LED strip chips. For example,

Wiring

APA020 and LPD880x

  1. Ensure your Zephyr board, the 5V power supply, and the LED strip share a common ground.

  2. Connect the MOSI pin of your board’s SPI master to the data input pin of the first IC in the strip.

  3. Connect the SCLK pin of your board’s SPI master to the clock input pin of the first IC in the strip.

  4. Connect the 5V power supply pin to the 5V input of the LED strip.

WS2812

  1. Ensure your Zephyr board, and the LED strip share a common ground.

  2. 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.

  3. 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_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_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

References