Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastSPI_LED2.h"
- #define NUM_LEDS 50 // Number of LED's
- CRGB leds[NUM_LEDS]; // This is an array of leds. One item for each led in your strip.
- // Not necessary to define SPI data, clock, etc pins because that is done in the FastSPI library
- // FastSPI recognizes arduino type
- int a=9,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;
- void setup() {
- delay(2000); // sanity check delay - allows reprogramming if accidently blowing power w/leds
- FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS); //chipset type
- }
- void loop() {
- //************************** AMERICA *********************************
- int NUM_LOOPS = 20;
- int LOOP_NUM = 0;
- while(a < 50){
- if(a < 9){ //for leds to come out 1 by one, can't assign leds[negative#] = ....
- for(int BEGIN = 0; BEGIN < 9; BEGIN ++){
- if(BEGIN >= 0) leds[BEGIN] = CRGB::Red; //if assign - number to led, program fails
- if(BEGIN > 0) leds[BEGIN - 1] = CRGB::Red;
- if(BEGIN > 1) leds[BEGIN - 2] = CRGB::White;
- if(BEGIN > 2) leds[BEGIN - 3] = CRGB::White;
- if(BEGIN > 3) leds[BEGIN - 4] = CRGB::White;
- if(BEGIN > 4) leds[BEGIN - 5] = CRGB::Blue;
- if(BEGIN > 5) leds[BEGIN - 6] = CRGB::Blue;
- if(BEGIN > 6) leds[BEGIN - 7] = CRGB::Blue;
- if(BEGIN > 7) leds[BEGIN - 8] = CRGB::Black;
- FastLED.show();
- delay(40);
- }
- }
- if(a >= 9){ //code to assign first led in the sequnce #8-49
- b = a-1;
- c = a-2;
- d = a-3;
- e = a-4;
- f = a-5;
- g = a-6;
- h = a-7;
- i = a-8;
- j = a-9;
- AMERICA(); // go to america function, assigns a-j leds their colors
- }
- if (a == 49){ //if first LED in chain has reached last LED
- LOOP_NUM++; // increment loop number
- if(LOOP_NUM == NUM_LOOPS-1){ //if the LED chain is on its last loop
- for(int END = 41; END < 50; END ++){
- if(END < 42) leds[END + 8] = CRGB::Red; //if assign -# to led, program fails
- if(END < 43) leds[END + 7] = CRGB::Red;
- if(END < 44) leds[END + 6] = CRGB::White;
- if(END < 45) leds[END + 5] = CRGB::White;
- if(END < 46) leds[END + 4] = CRGB::White;
- if(END < 47) leds[END + 3] = CRGB::Blue;
- if(END < 48) leds[END + 2] = CRGB::Blue;
- if(END < 49) leds[END + 1] = CRGB::Blue;
- if(END < 50) leds[END] = CRGB::Black;
- FastLED.show();
- delay(40);
- }
- break; //exit the while loop right here
- }
- for(int select = 0; select < 9; select++){ //allows for fluid LED49 TO LED 0 transition
- switch(select){
- case 0:
- a=0;b=49;c=48;d=47;e=46;f=45;g=44;h=43;i=42;j=41;
- AMERICA(); break;
- case 1:
- a=1;b=0;c=49;d=48;e=47;f=46;g=45;h=44;i=43;j=42;
- AMERICA(); break;
- case 2:
- a=2;b=1;c=0;d=49;e=48;f=47;g=46;h=45;i=44;j=43;
- AMERICA(); break;
- case 3:
- a=3;b=2;c=1;d=0;e=49;f=48;g=47;h=46;i=45;j=44;
- AMERICA(); break;
- case 4:
- a=4;b=3;c=2;d=1;e=0;f=49;g=48;h=47;i=46;j=45;
- AMERICA(); break;
- case 5:
- a=5;b=4;c=3;d=2;e=1;f=0;g=49;h=48;i=47;j=46;
- AMERICA(); break;
- case 6:
- a=6;b=5;c=4;d=3;e=2;f=1;g=0;h=49;i=48;j=47;
- AMERICA(); break;
- case 7:
- a=7;b=6;c=5;d=4;e=3;f=2;g=1;h=0;i=49;j=48;
- AMERICA(); break;
- case 8:
- a=8;b=7;c=6;d=5;e=4;f=3;g=2;h=1;i=0;j=49;
- AMERICA(); break;
- }
- }
- }
- a++; //increment a. if coming out of switch case, a now is 9.
- } //end of "a" while loop
- }
- void AMERICA(){
- leds[a] = CRGB::Red;
- leds[b] = CRGB::Red;
- leds[c] = CRGB::Red;
- leds[d] = CRGB::White;
- leds[e] = CRGB::White;
- leds[f] = CRGB::White;
- leds[g] = CRGB::Blue;
- leds[h] = CRGB::Blue;
- leds[i] = CRGB::Blue;
- leds[j] = CRGB::Black;
- FastLED.show();
- delay(40); //2 seconds for leds to loop
- }
Advertisement
Add Comment
Please, Sign In to add comment