Troubleshooting RGB LED Blinking Issue on ESP32-C3

Micael
Posts: 1
Joined: Mon Jun 19, 2023 5:43 pm

Troubleshooting RGB LED Blinking Issue on ESP32-C3

Postby Micael » Tue Jun 20, 2023 2:18 am

Hello,
I'm facing an issue with blinking the onboard RGB LED on my ESP32-C3-devKitM-1 board. According to the ESP32-C3 guide, the RGB LED is connected to GPIO 8. Although I can successfully make the LED blink using Arduino programming, I'm unable to achieve the same result when using C programming with the idf.py and ESP-IDF Framework. The RGB LED remains unresponsive.


Arduino code:
  1. void setup() {
  2.     pinMode(LED_BUILTIN, OUTPUT);
  3. }
  4.  
  5. void loop() {
  6.     digitalWrite(LED_BUILTIN, HIGH);
  7.     delay(1000);
  8.     digitalWrite(LED_BUILTIN, LOW);
  9.     delay(1000);
  10. }
C code using ESP-IDF framework:
  1. #define LED_PIN GPIO_NUM_8
  2.  
  3. void app_main(void){
  4.  
  5.     gpio_reset_pin(LED_PIN);
  6.     gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT_OD);
  7.  
  8.     while (1){
  9.             gpio_set_level(LED_PIN,1);
  10.             vTaskDelay(1000/portTICK_PERIOD_MS);
  11.  
  12.             gpio_set_level(LED_PIN,0);
  13.             vTaskDelay(1000/portTICK_PERIOD_MS);
  14.         }
  15.  
  16. }


Why is the RGB LED on my ESP32-C3-devKitM-1 board not blinking when I program it using the C programming language and the ESP-IDF Framework, despite being able to successfully achieve the blinking functionality using Arduino?

User avatar
ESP_krzychb
Posts: 396
Joined: Sat Oct 01, 2016 9:05 am
Contact:

Re: Troubleshooting RGB LED Blinking Issue on ESP32-C3

Postby ESP_krzychb » Tue Jun 20, 2023 4:15 am

Hello Micael, a series of pulses should be sent to addressable RGB LED to turn individual colors on or off. A single call to gpio_set_level() will send to a GPIO only a single on or off signal. Please check the original blink example from ESP-IDF for a complete code that is using led_strip driver to control addressable LEDs.

Who is online

Users browsing this forum: No registered users and 200 guests