ESP32-C6 RGB LED Control

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.

ESP32-C6 Board Overview

ESP32-C6 DevKitM-1 Board

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.

Key Features

Software Requirements

Installation

  1. Install the Arduino IDE from arduino.cc
  2. Add ESP32 board support to Arduino IDE:
  3. Install the Adafruit NeoPixel library:

Quick Start


#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);
}
    

Customization

Usage

  1. Download the esp32_c6_rgb_led_control.ino file
  2. Open the .ino file in Arduino IDE
  3. Select your ESP32-C6 board from Tools > Board menu
  4. Select the appropriate port from Tools > Port menu
  5. Click the Upload button to flash the code to your ESP32-C6

Contributing

Contributions 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.