zephyr/samples/basic/rgb_led
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
..
src zephyr: replace zephyr integer types with C99 types 2020-06-08 08:23:57 -05:00
CMakeLists.txt samples: make find_package(Zephyr...) REQUIRED 2020-05-29 10:47:25 +02:00
prj.conf samples: basic: remove whitelisting and use DT filters 2018-12-11 13:13:26 -06:00
README.rst samples: rgb_led: cleanups 2020-05-13 19:51:01 +02:00
sample.yaml tests: fix test identifiers 2019-12-09 15:53:44 -05:00

.. _rgb-led-sample:

PWM: RGB LED
############

Overview
********

This is a sample app which drives an RGB LED using PWM.

There are three single-color component LEDs in an RGB LED. Each component LED
is driven by a PWM port where the pulse width is changed from zero to a fusion
flicker threshold (the minimum flicker rate where the LED is perceived as being
steady), causing each component LED to step from dark to max brightness. Three
**for** loops (one for each component LED) generate a gradual range of color
changes from the RGB LED, and the sample repeats forever.

Requirements
************

The board must have red, green, and blue LEDs connected via PWM output channels.

The LED PWM channels must be configured using the following :ref:`devicetree
<dt-guide>` aliases, usually in the :ref:`BOARD.dts file
<devicetree-in-out-files>`:

- ``red-pwm-led``
- ``green-pwm-led``
- ``blue-pwm-led``

You will see at least one of these errors if you try to build this sample for
an unsupported board:

.. code-block:: none

   Unsupported board: red-pwm-led devicetree alias is not defined
   Unsupported board: green-pwm-led devicetree alias is not defined
   Unsupported board: blue-pwm-led devicetree alias is not defined

See :zephyr_file:`boards/arm/hexiwear_k64/hexiwear_k64.dts` for an example
:file:`BOARD.dts` file which supports this sample.

Wiring
******

No additional wiring is necessary if the required devicetree aliases refer to
hardware that is already connected to LEDs on the board.

Otherwise, LEDs should be connected to the appropriate PWM channels.

Building and Running
********************

For example, to build and flash this board for :ref:`hexiwear_k64`:

.. zephyr-app-commands::
   :zephyr-app: samples/basic/rgb_led
   :board: hexiwear_k64
   :goals: build flash
   :compact:

Change ``hexiwear_k64`` appropriately for other supported boards.