Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #define NUM_LEDS 30 // Number of LEDs in your strip
- #define DATA_PIN 6 // Data pin connected to your LED strip
- #define LED_TYPE WS2813 // Type of LED strip (e.g., WS2812B, NeoPixel)
- #define BRIGHTNESS 255 // Global brightness (0-255)
- #define SATURATION 255 // Global saturation (0-255)
- CRGB leds[NUM_LEDS]; // Array to store LED colors
- void setup() {
- FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, NUM_LEDS);
- FastLED.setBrightness(BRIGHTNESS);
- }
- void loop() {
- // Create a moving rainbow effect
- for (int j = 0; j < 255; j++) { // Loop through hues
- for (int i = 0; i < NUM_LEDS; i++) {
- // Assign a hue based on LED position and the current 'j' value
- leds[i] = CHSV(i * (255 / NUM_LEDS) + j, SATURATION, BRIGHTNESS);
- }
- FastLED.show(); // Update the LED strip
- delay(25); // Control animation speed
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment