cccdb3e4aa
Added the RMT/addr LED blink to the example and more detailed README.md Moved component/led_strip to common_components Added missing README file to common_components/led_strip README file update Makefile and Kconfig fixed for led_strip component Fixing end-of-line on main/blink.c Component updated to handle multiple instances Added note on the RMT channel number (ESP32 and ESP32-S2) Removed components folder from rmt/led_strip example and README updated Changed the led_strip_denit function and added ESP32-C3 RMT info on channel configuration Updates on README, Kconfig default settings and configure_led() function added |
||
---|---|---|
.. | ||
main | ||
CMakeLists.txt | ||
example_test.py | ||
Makefile | ||
README.md | ||
sdkconfig.defaults |
Blink Example
(See the README.md file in the upper level 'examples' directory for more information about examples.)
This example demonstrates how to blink a LED using GPIO or RMT for the addressable LED, i.e. WS2812.
See the RMT examples in the RMT Peripheral for more information about how to use it.
How to Use Example
Before project configuration and build, be sure to set the correct chip target using idf.py set-target <chip_name>
.
Hardware Required
- A development board with ESP32/ESP32-S2/ESP32-C3 SoC (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
- A USB cable for Power supply and programming
Some development boards use an addressable LED instead of a regular one. These development boards include:
Board | LED type | Pin |
---|---|---|
ESP32-C3-DevKitC-1 | Addressable | GPIO8 |
ESP32-C3-DevKitM-1 | Addressable | GPIO8 |
ESP32-S2-DevKitM-1 | Addressable | GPIO18 |
ESP32-S2-Saola-1 | Addressable | GPIO18 |
See Development Boards for more information about it.
Configure the Project
Open the project configuration menu (idf.py menuconfig
).
In the Example Configuration
menu:
- Select the LED type in the
Blink LED type
option.-
- Use
GPIO
for regular LED blink.
- Use
-
- Use
RMT
for addressable LED blink.
- Use
-
-
- Use
RMT Channel
to select the RMT peripheral channel.
- Use
-
-
- Set the GPIO number used for the signal in the
Blink GPIO number
option. - Set the blinking period in the
Blink period in ms
option.
Build and Flash
Run idf.py -p PORT flash monitor
to build, flash and monitor the project.
(To exit the serial monitor, type Ctrl-]
.)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
Example Output
As you run the example, you will see the LED blinking, according to the previously defined period. For the addressable LED, you can also change the LED color by setting the pStrip_a->set_pixel(pStrip_a, 0, 16, 16, 16);
(LED Strip, Pixel Number, Red, Green, Blue) with values from 0 to 255 in the blink.c
file.
Note: The color order could be different according to the LED model.
The pixel number indicates the pixel position in the LED strip. For a single LED, use 0.
Troubleshooting
- If the LED isn't blinking, check the GPIO or the LED type selection in the
Example Configuration
menu.
For any technical queries, please open an [issue] (https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.