| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #include <stdio.h>
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "driver/gpio.h"
- #include "esp_log.h"
- #include "led_strip.h"
- #include "sdkconfig.h"
- static const char *TAG = "LED_Control";
- led_strip_handle_t configure_led(void)
- {
- led_strip_config_t strip_config = {
- .strip_gpio_num = 38,
- .max_leds = 1,
- };
- // LED strip backend configuration: RMT
- led_strip_rmt_config_t rmt_config = {
- .clk_src = RMT_CLK_SRC_DEFAULT,
- .resolution_hz = (10 * 1000 * 1000),
- };
- led_strip_handle_t led_strip;
- ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
- ESP_LOGI(TAG, "Created LED strip object with RMT backend");
- return led_strip;
- }
- void LED_init(void)
- {
- led_strip_handle_t led_strip = configure_led();
- bool led_on_off = false;
- ESP_LOGI(TAG, "Start blinking LED strip");
- while (1) {
- if (led_on_off) {
- ESP_ERROR_CHECK(led_strip_set_pixel(led_strip, 0, 5, 5, 5));
- ESP_ERROR_CHECK(led_strip_refresh(led_strip));
- ESP_LOGI(TAG, "LED ON!");
- } else {
- ESP_ERROR_CHECK(led_strip_clear(led_strip));
- ESP_LOGI(TAG, "LED OFF!");
- }
- led_on_off = !led_on_off;
- vTaskDelay(pdMS_TO_TICKS(500));
- }
- }
|