Page 1 of 1

Troubleshooting RGB LED Blinking Issue on ESP32-C3

Posted: Tue Jun 20, 2023 2:18 am
by Micael
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?

Re: Troubleshooting RGB LED Blinking Issue on ESP32-C3

Posted: Tue Jun 20, 2023 4:15 am
by ESP_krzychb
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.