Created
December 17, 2016 02:25
-
-
Save marmilicious/69fecf8875e7cd2f4d63b8ee1a84be6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//*************************************************************** | |
// Custom marquee pattern example with "virtual holes" in the | |
// strip that are kept blacked out. | |
// | |
// Marc Miller, Dec 2016 | |
//*************************************************************** | |
#include "FastLED.h" | |
#define LED_TYPE LPD8806 | |
#define NUM_LEDS 32 | |
#define COLOR_ORDER GRB | |
//#define LED_TYPE APA102 | |
//#define NUM_LEDS 39 | |
//#define COLOR_ORDER BGR | |
#define DATA_PIN 11 | |
#define CLOCK_PIN 13 | |
CRGB leds[NUM_LEDS]; | |
#define BRIGHTNESS 32 | |
uint16_t holdTime = 80; // Milliseconds to hold position before advancing. | |
int16_t pos; // Used to store pixel position. | |
//--------------------------------------------------------------- | |
void setup() { | |
Serial.begin(115200); // Allows serial monitor output (check baud rate) | |
delay(3000); // Startup delay | |
FastLED.addLeds<LED_TYPE, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS); | |
FastLED.setBrightness(BRIGHTNESS); | |
} | |
//--------------------------------------------------------------- | |
void loop() { | |
EVERY_N_MILLISECONDS(holdTime){ // Advance pixels to next position. | |
for (uint8_t i=0; i<NUM_LEDS/4; i++){ | |
pos = (pos + 4) % NUM_LEDS; // Advance down strip and rollever if needed. | |
leds[pos] = CHSV(200,220,255); // purple | |
leds[pos-1 % NUM_LEDS] = CHSV(0,220,180); // red | |
leds[pos-2 % NUM_LEDS] = CHSV(96,220,200); // green | |
leds[pos-3 % NUM_LEDS] = CHSV(0,0,0); // black | |
} | |
BlackHoles(); // Black out "virtual holes" before displaying all pixels. | |
FastLED.show(); | |
pos = (pos + 1) % NUM_LEDS; // Advance down strip | |
} | |
}//end_main_loop | |
//--------------------------------------------------------------- | |
//Function to black out specific pixels | |
void BlackHoles() | |
{ | |
// List of pixels to always have blacked out | |
uint8_t holes[] = { | |
6,8,16,17,18,19,21 | |
}; | |
for (uint8_t i=0; i <= sizeof(holes); i++){ | |
leds[holes[i]] = CHSV(0,0,0); // black | |
} | |
}//end_BlackHoles | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment