arduino uno
3 x ws2811 leds connected in series
green wire (with brown extension) =====> digital pin 5
red wire (with black extension) =======> 5V (on power side)
white wire (with pale blue extension) ====> GND (on power side)
9V battery red wire =====> VIN (on power side)
9V battery black wire ====> GND (on power side)
use this code for constantly fluctuating colour changes
#include <FastLED.h>
#define DATA_PIN 5
#define NUM_LEDS 3
#define BRIGHTNESS 255 // Maximum brightness
CRGB leds[NUM_LEDS];
uint8_t hue = 0;
void setup() {
FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
// Set all LEDs to the same colour
fill_solid(leds, NUM_LEDS, CHSV(hue, 255, 255));
FastLED.show();
// Advance through the colour wheel
hue++;
// 256 steps × 20 ms ≈ 5.1 seconds per full rainbow cycle
delay(20);
}
