Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ColorPal
- By: Mark Kriegsman
- Modified by: Andrew Tuline
- This is a stripped down version of Mark Kriegsman's ColorPalette.ino.
- */
- #include "FastLED.h"
- #define LED_DT 12
- #define LED_CK 11
- #define NUM_LEDS 8
- #define BRIGHTNESS 16
- #define LED_TYPE WS2812B
- #define COLOR_ORDER GRB
- CRGB leds[NUM_LEDS];
- int indexinc = 3;
- uint8_t brightness = 64;
- uint8_t updates_per_second = 30;
- CRGBPalette16 currentPalette;
- TBlendType currentBlending;
- void setup() {
- delay(1000); // power-up safety delay
- FastLED.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // WS2812B
- // FastLED.addLeds<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(leds, NUM_LEDS); // WS2801 or APA102
- FastLED.setBrightness(BRIGHTNESS);
- currentPalette = OceanColors_p;
- //currentPalette = RainbowColors_p;
- //currentPalette = HeatColors_p;
- //currentPalette = PartyColors_p;
- //currentPalette = CloudColors_p;
- //currentPalette = RainbowStripeColors_p;
- //currentPalette = ForestColors_p;
- /* currentPalette = CRGBPalette16(
- 0x000008, 0x0000010, 0x000018, 0x000020, 0x000028, 0x000030, 0x000038, 0x000040,
- 0x000040, 0x0000038, 0x000030, 0x000028, 0x000020, 0x000018, 0x000010, 0x000008 );
- */
- currentBlending = BLEND;
- } //setup()
- void loop() {
- static uint8_t startIndex = 0;
- startIndex+=1;
- FillLEDsFromPaletteColors(startIndex);
- FastLED.show();
- FastLED.delay(1000/updates_per_second);
- } //loop()
- void FillLEDsFromPaletteColors(uint8_t colorIndex) {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
- colorIndex += indexinc;
- }
- } //FillLEDsFromPaletteColors()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement