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"
- #define NUM_LEDS 50
- #define DATA_PIN 3
- #define CHIPSET WS2812B
- #define BRIGHTNESS 50
- #define COLOR_ORDER GRB
- #define UPDATES_PER_SECOND 100
- CRGB rawleds[NUM_LEDS];
- CRGBSet leds(rawleds, NUM_LEDS);
- CRGBSet leds1(leds(0, 24));
- CRGBSet leds2(leds(25, 50));
- struct CRGB * ledarray[] = {leds1, leds2}; // An array of the CRGBSet arrays
- uint8_t sizearray[] = {25, 25}; // size of the above arrays
- CRGBPalette16 currentPalette;
- TBlendType currentBlending;
- extern CRGBPalette16 myRedWhiteBluePalette;
- extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;
- 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_max_power_indicator_LED(13);
- currentPalette = myRedWhiteBluePalette_p;
- currentBlending = LINEARBLEND;
- }
- void loop() {
- // fills the whole array
- arrayfill(CRGB::White, 700);
- arrayfill(CRGB::Blue, 700);
- //Circle around outside, heartbeat on inside
- heartbeat();
- // Fills one dot at a time
- colorwipe_dot(0, CRGB::White, 200);
- colorwipe_dot(1, CRGB::Blue, 200);
- fill_solid(leds, NUM_LEDS - 1, CRGB::Black);
- //red, white, and blue
- static uint8_t startIndex = 0;
- startIndex = startIndex + 1; /* motion speed */
- FillLEDsFromPaletteColors( startIndex);
- FastLED.show();
- FastLED.delay(1000 / UPDATES_PER_SECOND);
- }
- //================ New Functions =====================
- 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(wait);
- ledarray[y][dot] = CRGB::White;
- }
- }
- 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();
- }
- }
- 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 value
- leds[i] = CRGB::Blue;
- // now, let's first 20 leds to the top 20 leds,
- leds(NUM_LEDS / 2, NUM_LEDS - 1) = leds(NUM_LEDS / 2 - 1 , NUM_LEDS - 1);
- FastLED.delay(33);
- }
- }
- }
- void FillLEDsFromPaletteColors( uint8_t colorIndex)
- {
- uint8_t brightness = 255;
- for (byte i = 0; i < 5; i++) {
- for ( int i = 0; i < NUM_LEDS; i++) {
- leds[i] = ColorFromPalette( myRedWhiteBluePalette_p, colorIndex, BRIGHTNESS, currentBlending);
- colorIndex += 3;
- FastLED.delay(20);
- }
- }
- }
- const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
- {
- CRGB::Red,
- CRGB::Yellow, // 'white' is too bright compared to red and blue
- CRGB::Red,
- CRGB::Yellow,
- CRGB::Red,
- CRGB::Yellow, // 'white' is too bright compared to red and blue
- CRGB::Red,
- CRGB::Yellow,
- CRGB::Red,
- CRGB::Red,
- CRGB::Yellow,
- CRGB::Red,
- CRGB::Yellow,
- CRGB::Yellow,
- CRGB::Red,
- CRGB::Yellow
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement