Welcome to the ESP32-C6 built-in RGB LED Configuration Guide! This repository contains Arduino code for easily managing the built-in RGB LED on ESP32-C6 microcontrollers, perfect for IoT and embedded systems projects.
The image above shows the ESP32-C6 DevKitM-1 board. The built-in RGB LED is connected to GPIO 8, which is already configured in our code.
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
#include <Adafruit_NeoPixel.h>
#define LED_PIN 8 // The ESP32-C6 pin connected to the built-in RGB LED
#define NUM_LEDS 1
Adafruit_NeoPixel rgbLed(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
struct RGB {
uint8_t r, g, b;
};
constexpr RGB COLOR_OFF = {0, 0, 0};
constexpr RGB COLOR_RED = {255, 0, 0};
// ... Add more color definitions here
void setup() {
rgbLed.begin();
rgbLed.show();
}
void setColor(const RGB& color) {
rgbLed.setPixelColor(0, rgbLed.Color(color.r, color.g, color.b));
rgbLed.show();
}
void loop() {
setColor(COLOR_RED);
delay(500);
setColor(COLOR_OFF);
delay(500);
}
LED_PIN
is set to 8
for the built-in LED. Do not change this unless you're using an external LED.RGB
struct formatsetColor()
function with different delaysBLINK_DURATION
to change the speed of the blinking patternsetColor()
and blinkColor()
functionesp32_c6_rgb_led_control.ino
file.ino
file in Arduino IDEContributions to improve the code or add new features are welcome. Please feel free to submit a pull request or open an issue on the GitHub repository.