#include <FastLED.h>
// Define the number of LEDs and the data pin
#define NUM_LEDS 4
#define DATA_PIN 6 // Change this to the pin you're using for the WS2812B
CRGB leds[NUM_LEDS];
// Variables for the rainbow color cycling
uint8_t hue = 0;
void setup() {
// Initialize the FastLED library
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(100); // Adjust brightness from 0 to 255
}
void loop() {
// Cycle through all the colors of the rainbow
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV(hue + (i * 10), 255, 255); // Spread the hues across the LEDs
}
FastLED.show(); // Display the colors on the LEDs
hue++; // Increment the hue to move through the rainbow
delay(50); // Adjust speed of the color change
}
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1