/* * ============================================================================= * Fab Academy 2026 — Week 15 — Yaroslav Artsishevskiy * Simple rainbow blinking LED strip * ----------------------------------------------------------------------------- * 30 WS2812B LEDs connected to the XIAO ESP32-C3 expansion board: * Data line --> D0 (the A0/D0 Grove connector) * 5V --> 5V pad on the expansion board * GND --> any GND pad * * What it does: * Every half-second, the whole strip flashes a different rainbow color. * One color at a time, all 30 LEDs the same color, then it changes. * * Library needed: * FastLED (Arduino IDE → Library Manager → search "FastLED" → install) * ============================================================================= */ #include #define LED_PIN D0 // data pin — A0/D0 Grove connector #define NUM_LEDS 30 // 30 LEDs in the strip #define BRIGHTNESS 60 // out of 255 — keep it modest for USB power safety // FastLED's framebuffer — one CRGB color per LED CRGB leds[NUM_LEDS]; // Which hue to show next. Hue is 0..255 in FastLED (a full color wheel). // We add 32 each time so we step through ~8 distinct colors before looping. uint8_t currentHue = 0; void setup() { Serial.begin(115200); // Tell FastLED about the strip FastLED.addLeds(leds, NUM_LEDS); FastLED.setBrightness(BRIGHTNESS); FastLED.clear(); FastLED.show(); Serial.println("Rainbow blink ready"); } void loop() { // ---- Show: fill the whole strip with the current hue ---- // CHSV is "color from hue, saturation, value": // hue = currentHue (which color on the wheel) // saturation = 255 (fully saturated, no white mixed in) // value = 255 (full brightness — global brightness still caps it) fill_solid(leds, NUM_LEDS, CHSV(currentHue, 255, 255)); FastLED.show(); delay(500); // stay on this color for half a second // ---- Hide: turn the strip off briefly (the "blink" part) ---- FastLED.clear(); FastLED.show(); delay(150); // off for 150 ms // ---- Step to the next color in the rainbow ---- currentHue += 32; }