Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
---|
(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.
Before project configuration and build, be sure to set the correct chip target using idf.py set-target <chip_name>
.
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 |
ESP32-S3-DevKitC-1 | Addressable | GPIO48 |
See Development Boards for more information about it.
Open the project configuration menu (idf.py menuconfig
).
In the Example Configuration
menu:
Blink LED type
option.
GPIO
for regular LED blink.Blink GPIO number
option.Blink period in ms
option.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.
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 led_strip_set_pixel(led_strip, 0, 16, 16, 16);
(LED Strip, Pixel Number, Red, Green, Blue) with values from 0 to 255 in the source file.
I (315) example: Example configured to blink addressable LED!
I (325) example: Turning the LED OFF!
I (1325) example: Turning the LED ON!
I (2325) example: Turning the LED OFF!
I (3325) example: Turning the LED ON!
I (4325) example: Turning the LED OFF!
I (5325) example: Turning the LED ON!
I (6325) example: Turning the LED OFF!
I (7325) example: Turning the LED ON!
I (8325) example: Turning the LED OFF!
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.
Example Configuration
menu.For any technical queries, please open an issue on GitHub. We will get back to you soon.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。