Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #define LED_PIN 6
- #define LED_PIN_2 7
- #define NUM_LEDS 57
- #define NUMB_LEDS 40
- #define BRIGHTNESS 255
- #define BRIGHTNESS2 55
- #define LED_TYPE WS2812
- #define COLOR_ORDER GRB
- CRGB leds[NUM_LEDS];
- CRGB leds2[NUMB_LEDS];
- #define UPDATES_PER_SECOND 100
- CRGBPalette16 currentPalette;
- TBlendType currentBlending;
- extern CRGBPalette16 LavaColors;
- extern const TProgmemPalette16 LavaColors_p PROGMEM;
- void setup() {
- delay( 3000 ); // power-up safety delay
- FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
- FastLED.setBrightness( BRIGHTNESS );
- FastLED.addLeds<LED_TYPE, LED_PIN_2>(leds2, NUMB_LEDS).setCorrection (TypicalLEDStrip);
- FastLED.setBrightness( BRIGHTNESS2 );
- currentPalette = LavaColors_p;
- currentBlending = LINEARBLEND;
- }
- void loop()
- {
- static uint8_t startIndex = 0;
- startIndex = startIndex + 1; /* motion speed */
- FillLEDsFromPaletteColors( startIndex);
- FastLED.show();
- FastLED.delay(1000 / UPDATES_PER_SECOND);
- for(int i = 0; i < NUMB_LEDS; i++)
- leds2[i] = 0xffffff;
- }
- void FillLEDsFromPaletteColors( uint8_t colorIndex)
- {
- uint8_t brightness = 255;
- for( int i = 0; i < NUM_LEDS; i++) {
- leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
- colorIndex += 3;
- }
- }
- // There are several different palettes of colors demonstrated here.
- //
- // FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
- // OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement