Control the onboard LED on the ESP32-S3 - ESP32-S3-DevKitC-1

mediaRif
Posts: 10
Joined: Tue Mar 22, 2022 5:04 am

Control the onboard LED on the ESP32-S3 - ESP32-S3-DevKitC-1

Postby mediaRif » Tue Mar 28, 2023 4:45 am

I am trying to create the most simple way to control the on board LED on the ESP32-S3-DevKitC-1. I am using IDF 5.0.1. Using the component registry I am planning to use the LED_strip component. The documentation for the component in the component registry shows the following (as the most simple way for configuration of the LED_strip):

https://components.espressif.com/compon ... /led_strip

#define BLINK_GPIO 0

led_strip_handle_t led_strip;

/* LED strip initialization with the GPIO and pixels number*/
led_strip_config_t strip_config = {
.strip_gpio_num = BLINK_GPIO, // The GPIO that connected to the LED strip's data line
.max_leds = 1, // The number of LEDs in the strip,
.led_pixel_format = LED_PIXEL_FORMAT_GRB, // Pixel format of your LED strip
.led_model = LED_MODEL_WS2812, // LED strip model
.flags.invert_out = false, // whether to invert the output signal (useful when your hardware has a level inverter)
};

led_strip_rmt_config_t rmt_config = {
.clk_src = RMT_CLK_SRC_DEFAULT, // different clock source can lead to different power consumption
.resolution_hz = 10 * 1000 * 1000, // 10MHz
.flags.with_dma = false, // whether to enable the DMA feature
};
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));


My question: What would be a simple function that allows to assign the RGB values using this configuration?

blanchehermine
Posts: 16
Joined: Wed Mar 22, 2023 8:11 am

Re: Control the onboard LED on the ESP32-S3 - ESP32-S3-DevKitC-1

Postby blanchehermine » Wed Mar 29, 2023 5:33 am

There's an example in the esp-idf-v5.0.1\examples\get-started\blink folder, which has a function

Code: Select all

static void blink_led(void)
{
    /* If the addressable LED is enabled */
    if (s_led_state) {
        /* Set the LED pixel using RGB from 0 (0%) to 255 (100%) for each color */
        led_strip_set_pixel(led_strip, 0, 16, 16, 16);
        /* Refresh the strip to send data */
        led_strip_refresh(led_strip);
    } else {
        /* Set all LED off to clear all pixels */
        led_strip_clear(led_strip);
    }
}
Use led_strip_set_pixel() function to assign RGB color to the LED.

mediaRif
Posts: 10
Joined: Tue Mar 22, 2022 5:04 am

Re: Control the onboard LED on the ESP32-S3 - ESP32-S3-DevKitC-1

Postby mediaRif » Fri Mar 31, 2023 4:10 pm

Yes, this is what I was looking for, thank you so much! ...

Who is online

Users browsing this forum: No registered users and 55 guests