1.. zephyr:code-sample:: led-strip
2   :name: LED strip
3   :relevant-api: led_strip_interface
4
5   Control an LED strip.
6
7Overview
8********
9
10This sample application demonstrates basic usage of the LED strip.
11
12Requirements
13************
14
15Zephyr supports various LED strip chips. For example,
16
17- WS2812, such as the `NeoPixel(WS2812 compatible) LED Strip from AdaFruit`_.
18- APA102, such as the `Dotstar(APA102 compatible) LED Strip from AdaFruit`_.
19- LPD8806, such as the `LPD8806 LED Strip from AdaFruit`_.
20
21- Power supply. These LED strips usually require a 5V supply.
22
23- If the LED strip connects to the SPI bus, SPI communications usually use 5V
24  signaling, which may require a level translator, such as the
25  `74AHCT125 datasheet`_.
26
27.. _NeoPixel(WS2812 compatible) LED Strip from AdaFruit: https://www.adafruit.com/product/3919
28.. _Dotstar(APA102 compatible) LED Strip from AdaFruit: https://www.adafruit.com/product/2242
29.. _LPD8806 LED Strip from AdaFruit: https://www.adafruit.com/product/1948
30.. _74AHCT125 datasheet: https://cdn-shop.adafruit.com/datasheets/74AHC125.pdf
31
32Wiring
33******
34
35APA020 and LPD880x
36==================
37
38#. Ensure your Zephyr board, the 5V power supply, and the LED strip
39   share a common ground.
40#. Connect the MOSI pin of your board's SPI master to the data input
41   pin of the first IC in the strip.
42#. Connect the SCLK pin of your board's SPI master to the clock input
43   pin of the first IC in the strip.
44#. Connect the 5V power supply pin to the 5V input of the LED strip.
45
46WS2812
47======
48
49#. Ensure your Zephyr board, and the LED strip share a common ground.
50#. Connect the LED strip control pin (either I2S SDOUT, SPI MOSI or GPIO) from
51   your board to the data input pin of the first WS2812 IC in the strip.
52#. Power the LED strip at an I/O level compatible with the control pin signals.
53
54Note about thingy52
55-------------------
56
57The thingy52 has integrated NMOS transistors, that can be used instead of a level shifter.
58The I2S driver supports inverting the output to suit this scheme, using the ``out-active-low`` dts
59property. See the overlay file
60:zephyr_file:`samples/drivers/led/led_strip/boards/thingy52_nrf52832.overlay` for more detail.
61
62Building and Running
63********************
64
65The sample updates the LED strip periodically. The update frequency can be
66modified by changing the :kconfig:option:`CONFIG_SAMPLE_LED_UPDATE_DELAY`.
67
68Then build and flash the application:
69
70.. zephyr-app-commands::
71   :zephyr-app: samples/drivers/led/led_strip
72   :board: <board>
73   :goals: flash
74   :compact:
75
76When you connect to your board's serial console, you should see the
77following output:
78
79.. code-block:: none
80
81   ***** Booting Zephyr OS build v2.1.0-rc1-191-gd2466cdaf045 *****
82   [00:00:00.005,920] <inf> main: Found LED strip device WS2812
83   [00:00:00.005,950] <inf> main: Displaying pattern on strip
84
85References
86**********
87
88- `WS2812 datasheet`_
89- `LPD8806 datasheet`_
90- `APA102C datasheet`_
91- `74AHCT125 datasheet`_
92- `RGB LED strips: an overview`_
93- An excellent `blog post on WS2812 timing`_.
94
95.. _WS2812 datasheet: https://cdn-shop.adafruit.com/datasheets/WS2812.pdf
96.. _LPD8806 datasheet: https://cdn-shop.adafruit.com/datasheets/lpd8806+english.pdf
97.. _APA102C datasheet: https://cdn-shop.adafruit.com/product-files/2477/APA102C-iPixelLED.pdf
98.. _blog post on WS2812 timing: https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/
99.. _RGB LED strips\: an overview: http://nut-bolt.nl/2012/rgb-led-strips/
100