Skip to content

Instantly share code, notes, and snippets.

@ratkins
Created February 22, 2017 20:32
Show Gist options
  • Save ratkins/d9618d2a077058e465ae53f95601b223 to your computer and use it in GitHub Desktop.
Save ratkins/d9618d2a077058e465ae53f95601b223 to your computer and use it in GitHub Desktop.
#include "FastLED.h"
#include <stdio.h>
const uint8_t ledPin = 2;
//37 + (18 * 2) + (14 * 4)
const uint16_t kNumLeds = 129;
CRGB leds[kNumLeds];
CHSVPalette16 RainbowColorsHSV_p = (
CHSV(HUE_RED, 255, 255),
CHSV(HUE_ORANGE, 255, 255),
CHSV(HUE_YELLOW, 255, 255),
CHSV(HUE_GREEN, 255, 255),
CHSV(HUE_AQUA, 255, 255),
CHSV(HUE_BLUE, 255, 255),
CHSV(HUE_PURPLE, 255, 255),
CHSV(HUE_PINK, 255, 255)
);
CHSVPalette16 currentPalette = RainbowColorsHSV_p;
uint8_t paletteIndex = 0;
void setup() {
delay(2000);
Serial.begin(115200);
FastLED.addLeds<WS2812, ledPin, GRB>(leds, kNumLeds);
FastLED.setBrightness(128);
}
void loop() {
CHSV color = ColorFromPalette(currentPalette, paletteIndex++);
Serial.print(paletteIndex); Serial.print(" ");
Serial.print(color.h); Serial.print(" ");
Serial.print(color.s); Serial.print(" ");
Serial.print(color.v); Serial.print(" ");
Serial.println();
fill_solid(leds, kNumLeds, color);
LEDS.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment