Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Arduino.h>
- #include <FastLED.h>
- // --- LED Configuration ---
- #define NUM_LEDS 16
- #define DATA_PIN 17
- #define BRIGHTNESS 64 // Use a moderate brightness for testing (0-255)
- // --- Global Variables ---
- CRGB leds[NUM_LEDS];
- void setup() {
- Serial.begin(115200);
- delay(1000); // A small delay to let the serial monitor connect
- Serial.println("ESP32-S3 FastLED Standalone Test");
- Serial.println("Starting left-to-right sweep...");
- // Initialize the LED strip
- FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS);
- FastLED.setBrightness(BRIGHTNESS);
- // Start with all LEDs off
- FastLED.clear();
- FastLED.show();
- }
- void loop() {
- // --- SWEEP UP (Green to Red) ---
- for (int ledsToLight = 0; ledsToLight <= NUM_LEDS; ledsToLight++) {
- // First, clear all LEDs to black
- FastLED.clear();
- // Then, light up the ones we need for this frame
- for (int i = 0; i < ledsToLight; i++) {
- // Map the LED index to a hue from Green (96) to Red (0)
- uint8_t hue = map(i, 0, NUM_LEDS - 1, 96, 0);
- leds[i] = CHSV(hue, 255, 255);
- }
- FastLED.show();
- delay(50); // Controls the speed of the sweep
- }
- delay(500); // Pause with all LEDs lit red before repeating
- }
Advertisement
Add Comment
Please, Sign In to add comment