Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- FASTLED_USING_NAMESPACE
- //credit to -Mark Kriegsman
- //credit to -Marc Miller
- #if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
- #warning "Requires FastLED 3.1 or later; check github for latest code."
- #endif
- #define DATA_PIN 7
- #define CLK_PIN 11
- #define SPISpeed 16
- #define LED_TYPE APA102
- #define COLOR_ORDER RGB
- #define NUM_LEDS 144
- #define BRIGHTNESS 96
- #define FRAMES_PER_SECOND 120
- uint8_t pps = 24; // number of Pixels Per Segment
- int pos;
- uint8_t NumStrips=2;
- uint8_t delta =1;
- CRGBArray<NUM_LEDS> leds;
- // Name segments (based on layout in link above) and define pixel ranges.
- CRGBSet Strip_1( leds(pps*0, pps-1+(pps*0) ));
- //CRGBSet Strip_2( leds(pps*1, pps-1+(pps*1) )); //if i uncomment and comment the next line (strip_1 and strip_2)pixels are moving in one direction
- CRGBSet Strip_2( leds((pps-1)+(pps*1), pps*1 )); //if i uncomment and comment the previuos line strip_2 pixels are not moving in opposite direction
- CRGBSet Strip_3( leds(pps*2, pps-1+(pps*2) ));
- CRGBSet Strip_4( leds(pps*3, pps-1+(pps*3) ));
- CRGBSet Strip_5( leds(pps*4, pps-1+(pps*4) ));
- CRGBSet Strip_6( leds(pps*5, pps-1+(pps*5) ));
- struct CRGB * LEDArray[] ={Strip_1, Strip_2, Strip_3, Strip_4, Strip_5, Strip_6};
- void setup() {
- delay(3000); // 3 second delay for recovery
- // tell FastLED about the LED strip configuration
- // FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER,DATA_RATE_MHZ(SPISpeed)>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
- // set master brightness control
- FastLED.setBrightness(BRIGHTNESS);
- }
- // List of patterns to cycle through. Each is defined as a separate function below.
- typedef void (*SimplePatternList[])();
- SimplePatternList gPatterns = { white_dot, Blue_dot };
- uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
- void loop()
- {
- // Call the current pattern function once, updating the 'leds' array
- gPatterns[gCurrentPatternNumber]();
- EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
- }
- #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
- void nextPattern()
- {
- // add one to the current pattern number, and wrap around at the end
- gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
- }
- void white_dot()
- {
- EVERY_N_MILLISECONDS( 20 ){
- for (int y=0; y < NumStrips; y++ ) {
- LEDArray[y][pos] = CRGB::White;
- }
- FastLED.show();
- for (int y=0; y < NumStrips; y++ ) {
- LEDArray[y][pos] = CRGB::Black;
- }
- pos = (pos + delta + pps) % pps ;
- }
- }
- void Blue_dot()
- {
- EVERY_N_MILLISECONDS( 20 ) {
- for (int y=0; y < NumStrips; y++ ) {
- LEDArray[y][pos] = CRGB::Blue;
- }
- FastLED.show();
- for (int y=0; y < NumStrips; y++ ) {
- LEDArray[y][pos] = CRGB::Black;
- }
- pos = (pos + delta + pps) % pps ;
- }
- }
Add Comment
Please, Sign In to add comment