Created
June 14, 2016 18:05
-
-
Save Tejkaran/dffc97075f1b632534707af330e2864f 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
#include "FastLED.h" | |
#include <SPI.h> | |
#define NumOfStrips 4 | |
#define NumPixels 300 | |
#define DataRate_Mhz 12 | |
CRGB leds[NumOfStrips][NumPixels * NumOfStrips]; | |
int g, r, b, t; | |
int head=-1, tail=(head-2); | |
int Speed, LEDInterval; | |
int previousmicros; | |
void setup() | |
{ | |
FastLED.addLeds<APA102,11,13, BGR,DATA_RATE_MHZ(DataRate_Mhz)>(leds[0],NumPixels); //datapin is green, clockpin is blue | |
FastLED.addLeds<APA102,7, 14, BGR,DATA_RATE_MHZ(DataRate_Mhz)>(leds[1],NumPixels); | |
FastLED.addLeds<APA102,7, 13, BGR,DATA_RATE_MHZ(DataRate_Mhz)>(leds[2],NumPixels); | |
FastLED.addLeds<APA102,11,14, BGR,DATA_RATE_MHZ(DataRate_Mhz)>(leds[3],NumPixels); | |
Serial.begin(115200); | |
fill_solid(leds[0], NumPixels, CRGB(0,0,0)); | |
fill_solid(leds[1], NumPixels, CRGB(0,0,0)); | |
fill_solid(leds[2], NumPixels, CRGB(0,0,0)); | |
fill_solid(leds[3], NumPixels, CRGB(0,0,0)); | |
FastLED.show(); | |
delay(3000); | |
} | |
void loop() | |
{ | |
Speed = 1.00*1000000, g=255, r=0, b=255; | |
LEDInterval = (Speed/NumPixels); | |
while(t<=NumOfStrips-1) | |
{ | |
while(head<=NumPixels-1) | |
{ | |
float currentmicros = micros(); | |
if(currentmicros-previousmicros>= LEDInterval) | |
{ | |
Serial.print("Head Equals "); Serial.println(head); | |
Serial.print("Interval Equals "); Serial.println(currentmicros-previousmicros); | |
Serial.print("Time Equals "); Serial.println(micros()); | |
Serial.print("t Equals "); Serial.println(t); | |
Serial.println(""); | |
previousmicros = currentmicros; | |
leds[t][head] = CRGB(g,r,b); // head | |
leds[t][tail] = CRGB(0,0,0); // tail | |
if(t>0) leds[t-1][tail] = CRGB(0,0,0); // tail for previous strip | |
FastLED.show(); // show | |
if(tail>=NumPixels-1) tail=0; | |
else(++tail); | |
++head; | |
} | |
} | |
++t; | |
if(t<=NumOfStrips-1) head=0; | |
else{head=9999;} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment