Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Main File for design sketches for my DIY VW symbol
- // Bits of sketch taken from Chemdoc77 and others--
- #include "FastLED.h" //Always start FastLED sketches with this
- #define NUM_LEDS 50 //How many LEDs are you controlling?
- #define DATA_PIN 3 //What data pin are you connecting to on your controller?
- #define CHIPSET WS2812B //What chipset are your LEDs?
- #define BRIGHTNESS 50 //Enter a value between 0-255
- #define COLOR_ORDER GRB //If your colors are wrong on your LEDs, change the order of GRB
- //#define UPDATES_PER_SECOND 1000
- //================ Setup LED Arrays =====================
- CRGB rawleds[NUM_LEDS];
- CRGBSet leds(rawleds, NUM_LEDS);
- CRGBSet leds1(leds(0, 24));
- CRGBSet leds2(leds(25, 50));
- struct CRGB * ledarray[] = {leds1, leds2}; // Make sure to include all of the arrays you set up above between the {}
- uint8_t sizearray[] = {25, 25}; // size of each above arrays
- CRGBPalette16 currentPalette; // Do not change
- TBlendType currentBlending; //Do not change
- extern CRGBPalette16 myRedWhiteBluePalette; //Input palette name you define later
- extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;//Input palette name you define later
- //================ Setup =====================
- void setup() {
- delay( 3000 ); // power-up safety delay
- FastLED.addLeds<WS2812B, DATA_PIN, GRB>(rawleds, NUM_LEDS).setCorrection( TypicalLEDStrip );
- FastLED.setBrightness( BRIGHTNESS );
- FastLED.setMaxPowerInVoltsAndMilliamps(5, 1500); // Set power limit to make lights, not smoke.
- set_max_power_indicator_LED(13);
- currentPalette = myRedWhiteBluePalette_p; //enter the palette name youd like you run
- currentBlending = LINEARBLEND; //NOBLEND OR LINEARBLEND
- }
- //================ Loop =====================
- void loop() {
- static uint8_t startIndex = 0;
- startIndex = startIndex + 1; /* motion speed */
- //================ Sequence ===================== //edit out or add effects here
- arrayfill(CRGB::White, 700);// fills the whole array
- arrayfill(CRGB::Blue, 700); // fills the whole array
- heartbeat();//Circle around outside, heartbeat on inside
- colorwipe_dot(0, CRGB::White, 200);// Fills one dot at a time
- colorwipe_dot(1, CRGB::Blue, 200);// Fills one dot at a time
- fill_solid(leds, NUM_LEDS - 1, CRGB::White); //turn LEDs off
- FillLEDsFromPaletteColors( startIndex);//linear motion effect from palette defined below
- colorwipe_dot(0, CRGB::White, 200);// Fills one dot at a time
- colorwipe_dot(1, CRGB::Blue, 200);// Fills one dot at a time
- FastLED.delay(30);
- }
- //================ Functions =====================
- //Define your functions here
- //--------------------- Colorwipe ---------------------
- void colorwipe_dot(uint8_t y, CRGB color, uint32_t wait) { //Note: y is ledarray number
- for (uint8_t dot = 0; dot < sizearray[y]; dot++) {
- ledarray[y][dot] = color;
- FastLED.delay(80);
- ledarray[y][dot] = CRGB::White;
- }
- }
- //--------------------- Arrayfill ---------------------
- void arrayfill(CRGB color, uint16_t wait) {
- for (uint8_t x = 0; x < 2; x++) {
- fill_solid(ledarray[x], sizearray[x], color);
- FastLED.show();
- delay(wait);
- fill_solid( ledarray[x], sizearray[x], CRGB::Black);
- FastLED.show();
- }
- }
- //--------------------- Heartbeat ---------------------
- void heartbeat() {
- for (byte i = 0; i < 5; i++) {
- static uint8_t hue;
- for (int i = 0; i < NUM_LEDS / 2; i++) {
- // fade everything out
- leds.fadeToBlackBy(40);
- // let's set an led color
- leds[i] = CRGB::Blue;
- // now, let's first half leds to the top half leds,
- leds(NUM_LEDS / 2, NUM_LEDS - 1) = leds(NUM_LEDS / 2 - 1 , NUM_LEDS - 1);
- FastLED.delay(33);
- }
- }
- }
- //--------------------- FillLEDsFromPaletteColors ---------------------
- void FillLEDsFromPaletteColors( uint8_t colorIndex)
- {
- uint8_t brightness = 255;
- for (byte i = 0; i < 3; i++) {
- for ( int i = 0; i < NUM_LEDS; i++) {
- leds[i] = ColorFromPalette( myRedWhiteBluePalette_p, colorIndex, BRIGHTNESS, currentBlending);
- colorIndex +=3;
- FastLED.delay(20);
- }
- }
- }
- //--------------------- FillLEDsFromPaletteColors ---------------------
- //This is where you program your palette. Make sure your _p name is the same here as it is above.Change * in every CRGB::***** to a CRGB color .
- const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
- {
- CRGB::Red,
- CRGB::Black,
- CRGB::Yellow,
- CRGB::Black,
- CRGB::Red,
- CRGB::Black,
- CRGB::Yellow,
- CRGB::Black,
- CRGB::Red,
- CRGB::Black,
- CRGB::Yellow,
- CRGB::Black,
- CRGB::Red,
- CRGB::Black,
- CRGB::Black,
- CRGB::Yellow
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement