Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #define LED_PIN 5
- #define NUM_LEDS 300
- #define BRIGHTNESS 64
- #define LED_TYPE WS2811
- #define COLOR_ORDER RGB
- CRGB leds[NUM_LEDS];
- #define UPDATES_PER_SECOND 100
- // This example shows several ways to set up and use 'palettes' of colors
- // with FastLED.
- //
- // These compact palettes provide an easy way to re-colorize your
- // animation on the fly, quickly, easily, and with low overhead.
- //
- // USING palettes is MUCH simpler in practice than in theory, so first just
- // run this sketch, and watch the pretty lights as you then read through
- // the code. Although this sketch has eight (or more) different color schemes,
- // the entire sketch compiles down to about 6.5K on AVR.
- //
- // FastLED provides a few pre-configured color palettes, and makes it
- // extremely easy to make up your own color schemes with palettes.
- //
- // Some notes on the more abstract 'theory and practice' of
- // FastLED compact palettes are at the bottom of this file.
- int x = 0;
- // Get x value from Shuffleboard.
- int y = 1;
- CRGBPalette16 currentPalette;
- TBlendType currentBlending;
- extern CRGBPalette16 myRedWhiteBluePalette;
- extern const TProgmemPalette16 myRedWhiteBluePalette_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 );
- currentPalette = RainbowColors_p;
- currentBlending = LINEARBLEND;
- }
- void loop()
- {
- static uint8_t startIndex = 0;
- startIndex = startIndex + 1; /* motion speed */
- if (x == 0) {
- y = 0;
- for( int i = 0; y = 1; i++) {
- leds[i] = CRGB::Red;
- FastLED.show();
- if (x != 0) {
- int y = 1;
- }
- }
- }
- else if (x == 1) {
- y = 0;
- for( int i = 0; y = 1; i++) {
- leds[i] = CRGB::Blue;
- FastLED.show();
- if (x != 1) {
- int y = 1;
- }
- }
- }
- /*Was rainbow palette but doesn't work,
- FillLEDS to UPDATES_PER_SECONDS) };
- needs to be in a void loop(), but
- a void loop() can't be in another
- void loop, which we already have.
- So this code only runs red and blue.
- while (x == 2) {
- FillLEDsFromPaletteColors( startIndex);
- FastLED.show();
- FastLED.delay(1000 / UPDATES_PER_SECOND);
- }*/
- }
- void FillLEDsFromPaletteColors( uint8_t colorIndex)
- {
- uint8_t brightness = 255;
- }
- void ChangePalettePeriodically()
- {
- uint8_t secondHand = (millis() / 1000) % 60;
- static uint8_t lastSecond = 99;
- }
- const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
- {
- CRGB::Red,
- CRGB::Gray, // 'white' is too bright compared to red and blue
- CRGB::Blue,
- CRGB::Black,
- CRGB::Red,
- CRGB::Gray,
- CRGB::Blue,
- CRGB::Black,
- CRGB::Red,
- CRGB::Red,
- CRGB::Gray,
- CRGB::Gray,
- CRGB::Blue,
- CRGB::Blue,
- CRGB::Black,
- CRGB::Black
- };
Add Comment
Please, Sign In to add comment