Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*------------------------------------#
- #----- FASTSPI2 EFFECTS EXAMPLES -----#
- #-------------- v0.51 ----------------#
- #------------ teldredge --------------#
- #-------- www.funkboxing.com ---------#
- #------ [email protected] ------#
- #-------------------------------------#
- ### THESE EFFECTS ARE MOSTLY DESIGNED FOR A LOOP/RING OF LEDS
- ### BUT PLENTY USEFUL FOR OTHER CONFIGURATIONS
- ### RECENT CHANGES v0.51
- -ADDED SOFTWARE SERIAL FOR BLUETOOTH CONTROL
- -ADDED (z) SHOW LED COMMAND (FOR BETTER SERIAL CONTROL)
- -ADDED SET (a)ll LEDS TO COLOR HSV (0-255)
- -ADDED (c)lear FUNCTION
- -ADDED (v) SET INDIVIDUAL LED HSV FUNCTION
- -ADDED (Q)UERY VERSION NUMBER FUNCTION
- ### NOTES
- -MAKE SURE YOU ARE USING FAST_SPI RC3 OR LATER
- -THIS IS AN EXAMPLE LIBRARY SO YOU'LL PRABALY WANT TO EDIT TO DO ANYTHING USEFUL WITH IT
- -GOTO FUNKBOXING FAST_SPI2 COMMENTS PAGE FOR HELP
- -DEMO MODE BLOCKS SERIAL COMMANDS
- ### LICENSE:::USE FOR WHATEVER YOU WANT, WHENEVER YOU WANT, HOWEVER YOU WANT, WHYEVER YOU WANT
- ### BUT YOU MUST YODEL ONCE FOR FREEDOM AND MAYBE DONATE TO SOMETHING WORTHWHILE
- |-----------------------------------------------------|
- | |
- | FROM THE FAST_SPI2 EXAMPLE FILE |
- | |
- |----------------------------------------------------*/
- // Uncomment this line if you have any interrupts that are changing pins - this causes the library to be a little bit more cautious
- // #define FAST_SPI_INTERRUPTS_WRITE_PINS 1
- // Uncomment this line to force always using software, instead of hardware, SPI (why?)
- // #define FORCE_SOFTWARE_SPI 1
- // Uncomment this line if you want to talk to DMX controllers
- // #define FASTSPI_USE_DMX_SIMPLE 1
- //-----------------------------------------------------
- #include <SoftwareSerial.h>
- #include <FastLED.h>
- #include "Timer.h"
- Timer time;
- int newmode = 2;
- #define VERSION_NUMBER 0.51
- //---LED SETUP STUFF
- #define LED_COUNT 25 //FOR TESTING w/ SIGN
- #define NUM_LEDS 25
- #define DATA_PIN 12
- #define CLOCK_PIN 13
- #define NUM_LEDSPERROW 25
- long btnDnTime; // time the button was pressed down
- long btnUpTime; // time the button was released
- #define holdTime 3000 //used to time button hold for special function
- //#define buttonPin 3 //Default button pin, Pin 21 and 22 used for SPI
- int pbIn = 3; // Interrupt 0 is on DIGITAL PIN 2!
- volatile boolean buttonstate = 0; // The input state toggle NOT PRESSED = 0
- int BOTTOM_INDEX = 0;
- int TOP_INDEX = int(LED_COUNT/2);
- int EVENODD = LED_COUNT%2;
- struct CRGB leds[LED_COUNT];
- int ledsX[LED_COUNT][3]; //-ARRAY FOR COPYING WHATS IN THE LED STRIP CURRENTLY (FOR CELL-AUTOMATA, MARCH, ETC)
- int ledMode = 2; //- USES TIMER 30 seconds
- //volatile int ledMode = 888; //-START IN DEMO MODE
- //int ledMode = 6; //-MODE TESTING
- int thisdelay = 20; //-FX LOOPS DELAY VAR
- int thisstep = 10; //-FX LOOPS DELAY VAR
- int thishue = 0; //-FX LOOPS DELAY VAR
- int thissat = 255; //-FX LOOPS DELAY VAR
- int max_bright = 165; //-SET MAX BRIGHTNESS TO 1/4
- int thisindex = 0; //-SET SINGLE LED VAR
- int thisRED = 0;
- int thisGRN = 0;
- int thisBLU = 0;
- //---SERIAL/SOFTWARE SERIAL SETUP STUFF
- #define SERIAL_BAUDRATE 9600
- //---LED FX VARS
- int idex = 0; //-LED INDEX (0 to LED_COUNT-1
- int ihue = 0; //-HUE (0-255)
- int ibright = 0; //-BRIGHTNESS (0-255)
- int isat = 0; //-SATURATION (0-255)
- int bouncedirection = 0; //-SWITCH FOR COLOR BOUNCE (0-1)
- float tcount = 0.0; //-INC VAR FOR SIN LOOPS
- int lcount = 0; //-ANOTHER COUNTING VAR
- //------------------------------------- UTILITY FXNS --------------------------------------
- //---SET THE COLOR OF A SINGLE RGB LED
- void set_color_led(int adex, int cred, int cgrn, int cblu) {
- leds[adex].setRGB( cred, cgrn, cblu);
- }
- //---FIND INDEX OF HORIZONAL OPPOSITE LED
- int horizontal_index(int i) {
- //-ONLY WORKS WITH INDEX < TOPINDEX
- if (i == BOTTOM_INDEX) {return BOTTOM_INDEX;}
- if (i == TOP_INDEX && EVENODD == 1) {return TOP_INDEX + 1;}
- if (i == TOP_INDEX && EVENODD == 0) {return TOP_INDEX;}
- return LED_COUNT - i;
- }
- //---FIND INDEX OF ANTIPODAL OPPOSITE LED
- int antipodal_index(int i) {
- int iN = i + TOP_INDEX;
- if (i >= TOP_INDEX) {iN = ( i + TOP_INDEX ) % LED_COUNT; }
- return iN;
- }
- //---FIND ADJACENT INDEX CLOCKWISE
- int adjacent_cw(int i) {
- int r;
- if (i < LED_COUNT - 1) {r = i + 1;}
- else {r = 0;}
- return r;
- }
- //---FIND ADJACENT INDEX COUNTER-CLOCKWISE
- int adjacent_ccw(int i) {
- int r;
- if (i > 0) {r = i - 1;}
- else {r = LED_COUNT - 1;}
- return r;
- }
- void copy_led_array(){
- for(int i = 0; i < LED_COUNT; i++ ) {
- ledsX[i][0] = leds[i].r;
- ledsX[i][1] = leds[i].g;
- ledsX[i][2] = leds[i].b;
- }
- }
- //------------------------LED EFFECT FUNCTIONS------------------------
- void one_color_all(int cred, int cgrn, int cblu) { //-SET ALL LEDS TO ONE COLOR
- for(int i = 0 ; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[i].setRGB( cred, cgrn, cblu);
- }
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void one_color_allHSV(int ahue) { //-SET ALL LEDS TO ONE COLOR (HSV)
- for(int i = 0 ; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[i] = CHSV(ahue, thissat, 255);
- }
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void rainbow_fade() { //-m2-FADE ALL LEDS THROUGH HSV RAINBOW
- ihue++;
- if (ihue > 255) {ihue = 0;}
- for(int idex = 0 ; idex < LED_COUNT; idex++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[idex] = CHSV(ihue, thissat, 255);
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void rainbow_loop() { //-m3-LOOP HSV RAINBOW
- idex++;
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- ihue = ihue + thisstep;
- if (idex >= LED_COUNT) {idex = 0;}
- if (ihue > 255) {ihue = 0;}
- leds[idex] = CHSV(ihue, thissat, 255);
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void random_burst() { //-m4-RANDOM INDEX/COLOR
- idex = random(0, LED_COUNT);
- ihue = random(0, 255);
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[idex] = CHSV(ihue, thissat, 255);
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void color_bounce() { //-m5-BOUNCE COLOR (SINGLE LED)
- if (bouncedirection == 0) {
- idex = idex + 1;
- if (idex == LED_COUNT) {
- bouncedirection = 1;
- idex = idex - 1;
- }
- }
- if (bouncedirection == 1) {
- idex = idex - 1;
- if (idex == 0) {
- bouncedirection = 0;
- }
- }
- for(int i = 0; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- if (i == idex) {leds[i] = CHSV(thishue, thissat, 255);}
- else {leds[i] = CHSV(0, 0, 0);}
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void color_bounceFADE() { //-m6-BOUNCE COLOR (SIMPLE MULTI-LED FADE)
- if (bouncedirection == 0) {
- idex = idex + 1;
- if (idex == LED_COUNT) {
- bouncedirection = 1;
- idex = idex - 1;
- }
- }
- if (bouncedirection == 1) {
- idex = idex - 1;
- if (idex == 0) {
- bouncedirection = 0;
- }
- }
- int iL1 = adjacent_cw(idex);
- int iL2 = adjacent_cw(iL1);
- int iL3 = adjacent_cw(iL2);
- int iR1 = adjacent_ccw(idex);
- int iR2 = adjacent_ccw(iR1);
- int iR3 = adjacent_ccw(iR2);
- for(int i = 0; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- if (i == idex) {leds[i] = CHSV(thishue, thissat, 255);}
- else if (i == iL1) {leds[i] = CHSV(thishue, thissat, 150);}
- else if (i == iL2) {leds[i] = CHSV(thishue, thissat, 80);}
- else if (i == iL3) {leds[i] = CHSV(thishue, thissat, 20);}
- else if (i == iR1) {leds[i] = CHSV(thishue, thissat, 150);}
- else if (i == iR2) {leds[i] = CHSV(thishue, thissat, 80);}
- else if (i == iR3) {leds[i] = CHSV(thishue, thissat, 20);}
- else {leds[i] = CHSV(0, 0, 0);}
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void ems_lightsONE() { //-m7-EMERGENCY LIGHTS (TWO COLOR SINGLE LED)
- idex++;
- if (idex >= LED_COUNT) {idex = 0;}
- int idexR = idex;
- int idexB = antipodal_index(idexR);
- int thathue = (thishue + 160) % 255;
- for(int i = 0; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- if (i == idexR) {leds[i] = CHSV(thishue, thissat, 255);}
- else if (i == idexB) {leds[i] = CHSV(thathue, thissat, 255);}
- else {leds[i] = CHSV(0, 0, 0);}
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void ems_lightsALL() { //-m8-EMERGENCY LIGHTS (TWO COLOR SOLID)
- idex++;
- if (idex >= LED_COUNT) {idex = 0;}
- int idexR = idex;
- int idexB = antipodal_index(idexR);
- int thathue = (thishue + 160) % 255;
- leds[idexR] = CHSV(thishue, thissat, 255);
- leds[idexB] = CHSV(thathue, thissat, 255);
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void flicker() { //-m9-FLICKER EFFECT
- int random_bright = random(0,255);
- int random_delay = random(10,75);
- int random_bool = random(0,random_bright);
- if (random_bool < 10) {
- for(int i = 0 ; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[i] = CHSV(thishue, thissat, random_bright);
- }
- LEDS.show();
- FastLED.delay(random_delay);
- }
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void pulse_one_color_all() { //-m10-PULSE BRIGHTNESS ON ALL LEDS TO ONE COLOR
- if (bouncedirection == 0) {
- ibright++;
- if (ibright >= 255) {bouncedirection = 1;}
- }
- if (bouncedirection == 1) {
- ibright = ibright - 1;
- if (ibright <= 1) {bouncedirection = 0;}
- }
- for(int idex = 0 ; idex < LED_COUNT; idex++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[idex] = CHSV(thishue, thissat, ibright);
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void pulse_one_color_all_rev() { //-m11-PULSE SATURATION ON ALL LEDS TO ONE COLOR
- if (bouncedirection == 0) {
- isat++;
- if (isat >= 255) {bouncedirection = 1;}
- }
- if (bouncedirection == 1) {
- isat = isat - 1;
- if (isat <= 1) {bouncedirection = 0;}
- }
- for(int idex = 0 ; idex < LED_COUNT; idex++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[idex] = CHSV(thishue, isat, 255);
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void fade_vertical() { //-m12-FADE 'UP' THE LOOP
- idex++;
- if (idex > TOP_INDEX) {idex = 0;}
- int idexA = idex;
- int idexB = horizontal_index(idexA);
- ibright = ibright + 10;
- if (ibright > 255) {ibright = 0;}
- leds[idexA] = CHSV(thishue, thissat, ibright);
- leds[idexB] = CHSV(thishue, thissat, ibright);
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void random_red() { //QUICK 'N DIRTY RANDOMIZE TO GET CELL AUTOMATA STARTED
- int temprand;
- for(int i = 0; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- temprand = random(0,100);
- if (temprand > 50) {leds[i].r = 255;}
- if (temprand <= 50) {leds[i].r = 0;}
- leds[i].b = 0; leds[i].g = 0;
- }
- LEDS.show();
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void rule30() { //-m13-1D CELLULAR AUTOMATA - RULE 30 (RED FOR NOW)
- if (bouncedirection == 0) {
- random_red();
- bouncedirection = 1;
- }
- copy_led_array();
- int iCW;
- int iCCW;
- int y = 100;
- for(int i = 0; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- iCW = adjacent_cw(i);
- iCCW = adjacent_ccw(i);
- if (ledsX[iCCW][0] > y && ledsX[i][0] > y && ledsX[iCW][0] > y) {leds[i].r = 0;}
- if (ledsX[iCCW][0] > y && ledsX[i][0] > y && ledsX[iCW][0] <= y) {leds[i].r = 0;}
- if (ledsX[iCCW][0] > y && ledsX[i][0] <= y && ledsX[iCW][0] > y) {leds[i].r = 0;}
- if (ledsX[iCCW][0] > y && ledsX[i][0] <= y && ledsX[iCW][0] <= y) {leds[i].r = 255;}
- if (ledsX[iCCW][0] <= y && ledsX[i][0] > y && ledsX[iCW][0] > y) {leds[i].r = 255;}
- if (ledsX[iCCW][0] <= y && ledsX[i][0] > y && ledsX[iCW][0] <= y) {leds[i].r = 255;}
- if (ledsX[iCCW][0] <= y && ledsX[i][0] <= y && ledsX[iCW][0] > y) {leds[i].r = 255;}
- if (ledsX[iCCW][0] <= y && ledsX[i][0] <= y && ledsX[iCW][0] <= y) {leds[i].r = 0;}
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void random_march() { //-m14-RANDOM MARCH CCW
- copy_led_array();
- int iCCW;
- leds[0] = CHSV(random(0,255), 255, 255);
- for(int idex = 1; idex < LED_COUNT ; idex++ ) {\
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- iCCW = adjacent_ccw(idex);
- leds[idex].r = ledsX[iCCW][0];
- leds[idex].g = ledsX[iCCW][1];
- leds[idex].b = ledsX[iCCW][2];
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void rwb_march() { //-m15-R,W,B MARCH CCW
- copy_led_array();
- int iCCW;
- idex++;
- if (idex > 2) {idex = 0;}
- switch (idex) {
- case 0:
- leds[0].r = 255;
- leds[0].g = 0;
- leds[0].b = 0;
- break;
- case 1:
- leds[0].r = 255;
- leds[0].g = 255;
- leds[0].b = 255;
- break;
- case 2:
- leds[0].r = 0;
- leds[0].g = 0;
- leds[0].b = 255;
- break;
- }
- for(int i = 1; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- iCCW = adjacent_ccw(i);
- leds[i].r = ledsX[iCCW][0];
- leds[i].g = ledsX[iCCW][1];
- leds[i].b = ledsX[iCCW][2];
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void radiation() { //-m16-SORT OF RADIATION SYMBOLISH-
- int N3 = int(LED_COUNT/3);
- int N6 = int(LED_COUNT/6);
- int N12 = int(LED_COUNT/12);
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- for(int i = 0; i < N6; i++ ) { //-HACKY, I KNOW...
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- tcount = tcount + .02;
- if (tcount > 3.14) {tcount = 0.0;}
- ibright = int(sin(tcount)*255);
- int j0 = (i + LED_COUNT - N12) % LED_COUNT;
- int j1 = (j0+N3) % LED_COUNT;
- int j2 = (j1+N3) % LED_COUNT;
- leds[j0] = CHSV(thishue, thissat, ibright);
- leds[j1] = CHSV(thishue, thissat, ibright);
- leds[j2] = CHSV(thishue, thissat, ibright);
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void color_loop_vardelay() { //-m17-COLOR LOOP (SINGLE LED) w/ VARIABLE DELAY
- idex++;
- if (idex > LED_COUNT) {idex = 0;}
- int di = abs(TOP_INDEX - idex);
- int t = constrain((10/di)*10, 10, 500);
- for(int i = 0; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- if (i == idex) {
- leds[i] = CHSV(0, thissat, 255);
- }
- else {
- leds[i].r = 0; leds[i].g = 0; leds[i].b = 0;
- }
- }
- LEDS.show();
- FastLED.delay(t);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void white_temps() { //-m18-SHOW A SAMPLE OF BLACK BODY RADIATION COLOR TEMPERATURES
- int N9 = int(LED_COUNT/9);
- for (int i = 0; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- if (i >= 0 && i < N9) {leds[i].r = 255; leds[i].g = 147; leds[i].b = 41;} //-CANDLE - 1900
- if (i >= N9 && i < N9*2) {leds[i].r = 255; leds[i].g = 197; leds[i].b = 143;} //-40W TUNG - 2600
- if (i >= N9*2 && i < N9*3) {leds[i].r = 255; leds[i].g = 214; leds[i].b = 170;} //-100W TUNG - 2850
- if (i >= N9*3 && i < N9*4) {leds[i].r = 255; leds[i].g = 241; leds[i].b = 224;} //-HALOGEN - 3200
- if (i >= N9*4 && i < N9*5) {leds[i].r = 255; leds[i].g = 250; leds[i].b = 244;} //-CARBON ARC - 5200
- if (i >= N9*5 && i < N9*6) {leds[i].r = 255; leds[i].g = 255; leds[i].b = 251;} //-HIGH NOON SUN - 5400
- if (i >= N9*6 && i < N9*7) {leds[i].r = 255; leds[i].g = 255; leds[i].b = 255;} //-DIRECT SUN - 6000
- if (i >= N9*7 && i < N9*8) {leds[i].r = 201; leds[i].g = 226; leds[i].b = 255;} //-OVERCAST SKY - 7000
- if (i >= N9*8 && i < LED_COUNT) {leds[i].r = 64; leds[i].g = 156; leds[i].b = 255;}//-CLEAR BLUE SKY - 20000
- }
- LEDS.show();
- FastLED.delay(100);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void sin_bright_wave() { //-m19-BRIGHTNESS SINE WAVE
- for(int i = 0; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- tcount = tcount + .1;
- if (tcount > 3.14) {tcount = 0.0;}
- ibright = int(sin(tcount)*255);
- leds[i] = CHSV(thishue, thissat, ibright);
- LEDS.show();
- FastLED.delay(thisdelay);
- }
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void pop_horizontal() { //-m20-POP FROM LEFT TO RIGHT UP THE RING
- int ix;
- if (bouncedirection == 0) {
- bouncedirection = 1;
- ix = idex;
- }
- else if (bouncedirection == 1) {
- bouncedirection = 0;
- ix = horizontal_index(idex);
- idex++;
- if (idex > TOP_INDEX) {idex = 0;}
- }
- for(int i = 0; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- if (i == ix) {
- leds[i] = CHSV(thishue, thissat, 255);
- }
- else {
- leds[i].r = 0; leds[i].g = 0; leds[i].b = 0;
- }
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void quad_bright_curve() { //-m21-QUADRATIC BRIGHTNESS CURVER
- int ax;
- for(int x = 0; x < LED_COUNT; x++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- if (x <= TOP_INDEX) {ax = x;}
- else if (x > TOP_INDEX) {ax = LED_COUNT-x;}
- int a = 1; int b = 1; int c = 0;
- int iquad = -(ax*ax*a)+(ax*b)+c; //-ax2+bx+c
- int hquad = -(TOP_INDEX*TOP_INDEX*a)+(TOP_INDEX*b)+c;
- ibright = int((float(iquad)/float(hquad))*255);
- leds[x] = CHSV(thishue, thissat, ibright);
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void flame() { //-m22-FLAMEISH EFFECT
- int idelay = random(0,35);
- float hmin = 0.1; float hmax = 45.0;
- float hdif = hmax-hmin;
- int randtemp = random(0,3);
- float hinc = (hdif/float(TOP_INDEX))+randtemp;
- int ihue = hmin;
- for(int i = 0; i <= TOP_INDEX; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- ihue = ihue + hinc;
- leds[i] = CHSV(ihue, thissat, 255);
- int ih = horizontal_index(i);
- leds[ih] = CHSV(ihue, thissat, 255);
- leds[TOP_INDEX].r = 255; leds[TOP_INDEX].g = 255; leds[TOP_INDEX].b = 255;
- LEDS.show();
- FastLED.delay(idelay);
- }
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void rainbow_vertical() { //-m23-RAINBOW 'UP' THE LOOP
- idex++;
- if (idex > TOP_INDEX) {idex = 0;}
- ihue = ihue + thisstep;
- if (ihue > 255) {ihue = 0;}
- int idexA = idex;
- int idexB = horizontal_index(idexA);
- leds[idexA] = CHSV(ihue, thissat, 255);
- leds[idexB] = CHSV(ihue, thissat, 255);
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- // buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void pacman() { //-m24-REALLY TERRIBLE PACMAN CHOMPING EFFECT
- int s = int(LED_COUNT/4);
- lcount++;
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- if (lcount > 5) {lcount = 0;}
- if (lcount == 0) {
- for(int i = 0 ; i < LED_COUNT; i++ ) {set_color_led(i, 255, 255, 0);}
- }
- if (lcount == 1 || lcount == 5) {
- for(int i = 0 ; i < LED_COUNT; i++ ) {set_color_led(i, 255, 255, 0);}
- leds[s].r = 0; leds[s].g = 0; leds[s].b = 0;}
- if (lcount == 2 || lcount == 4) {
- for(int i = 0 ; i < LED_COUNT; i++ ) {set_color_led(i, 255, 255, 0);}
- leds[s-1].r = 0; leds[s-1].g = 0; leds[s-1].b = 0;
- leds[s].r = 0; leds[s].g = 0; leds[s].b = 0;
- leds[s+1].r = 0; leds[s+1].g = 0; leds[s+1].b = 0;}
- if (lcount == 3) {
- for(int i = 0 ; i < LED_COUNT; i++ ) {set_color_led(i, 255, 255, 0);}
- leds[s-2].r = 0; leds[s-2].g = 0; leds[s-2].b = 0;
- leds[s-1].r = 0; leds[s-1].g = 0; leds[s-1].b = 0;
- leds[s].r = 0; leds[s].g = 0; leds[s].b = 0;
- leds[s+1].r = 0; leds[s+1].g = 0; leds[s+1].b = 0;
- leds[s+2].r = 0; leds[s+2].g = 0; leds[s+2].b = 0;}
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void random_color_pop() { //-m25-RANDOM COLOR POP
- idex = random(0, LED_COUNT);
- ihue = random(0, 255);
- one_color_all(0, 0, 0);
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[idex] = CHSV(ihue, thissat, 255);
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void ems_lightsSTROBE() { //-m26-EMERGENCY LIGHTS (STROBE LEFT/RIGHT)
- int thishue = 0;
- int thathue = (thishue + 160) % 255;
- for(int x = 0 ; x < 5; x++ ) {
- for(int i = 0 ; i < TOP_INDEX; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[i] = CHSV(thishue, thissat, 255);
- }
- LEDS.show(); FastLED.delay(thisdelay);
- one_color_all(0, 0, 0);
- LEDS.show(); FastLED.delay(thisdelay);
- }
- for(int x = 0 ; x < 5; x++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- for(int i = TOP_INDEX ; i < LED_COUNT; i++ ) {
- leds[i] = CHSV(thathue, thissat, 255);
- }
- LEDS.show(); FastLED.delay(thisdelay);
- one_color_all(0, 0, 0);
- LEDS.show(); FastLED.delay(thisdelay);
- }
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void rgb_propeller() { //-m27-RGB PROPELLER
- idex++;
- int ghue = (thishue + 80) % 255;
- int bhue = (thishue + 160) % 255;
- int N3 = int(LED_COUNT/3);
- int N6 = int(LED_COUNT/6);
- int N12 = int(LED_COUNT/12);
- for(int i = 0; i < N3; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- int j0 = (idex + i + LED_COUNT - N12) % LED_COUNT;
- int j1 = (j0+N3) % LED_COUNT;
- int j2 = (j1+N3) % LED_COUNT;
- leds[j0] = CHSV(thishue, thissat, 255);
- leds[j1] = CHSV(ghue, thissat, 255);
- leds[j2] = CHSV(bhue, thissat, 255);
- }
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void kitt() { //-m28-KNIGHT INDUSTIES 2000
- int rand = random(0, TOP_INDEX);
- for(int i = 0; i < rand; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[TOP_INDEX+i] = CHSV(thishue, thissat, 255);
- leds[TOP_INDEX-i] = CHSV(thishue, thissat, 255);
- LEDS.show();
- FastLED.delay(thisdelay/rand);
- }
- for(int i = rand; i > 0; i-- ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[TOP_INDEX+i] = CHSV(thishue, thissat, 0);
- leds[TOP_INDEX-i] = CHSV(thishue, thissat, 0);
- LEDS.show();
- FastLED.delay(thisdelay/rand);
- }
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void matrix() { //-m29-ONE LINE MATRIX
- int rand = random(0, 75);
- if (rand > 90) {
- leds[0] = CHSV(thishue, thissat, 255);
- }
- else {leds[0] = CHSV(thishue, thissat, 0);}
- copy_led_array();
- for(int i = 1; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- leds[i].r = ledsX[i-1][0];
- leds[i].g = ledsX[i-1][1];
- leds[i].b = ledsX[i-1][2];
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void strip_march_cw() { //-m50-MARCH STRIP CW
- copy_led_array();
- int iCW;
- for(int i = 0; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- iCW = adjacent_cw(i);
- leds[i].r = ledsX[iCW][0];
- leds[i].g = ledsX[iCW][1];
- leds[i].b = ledsX[iCW][2];
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void strip_march_ccw() { //-m51-MARCH STRIP CCW
- copy_led_array();
- int iCCW;
- for(int i = 0; i < LED_COUNT; i++ ) {
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- iCCW = adjacent_ccw(i);
- leds[i].r = ledsX[iCCW][0];
- leds[i].g = ledsX[iCCW][1];
- leds[i].b = ledsX[iCCW][2];
- }
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void new_rainbow_loop(){ //-m88-RAINBOW FADE FROM FAST_SPI2
- ihue -= 1;
- fill_rainbow( leds, LED_COUNT, ihue );
- /*****************************************************************************/
- if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
- /*****************************************************************************/
- LEDS.show();
- FastLED.delay(thisdelay);
- /******************** END OF FUNCTION EFFECT *****************************/
- buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
- /******************** END OF FUNCTION EFFECT *****************************/
- }
- void demo_modeA(){
- int r = 15;
- thisdelay = 20; thisstep = 10; thishue = 0; thissat = 255;
- //one_color_all(255,255,255); LEDS.show(); FastLED.delay(1200);
- for(int i=0; i<r*35; i++) {if(buttonstate){}; thisdelay = 40; rainbow_fade();}
- for(int i=0; i<r*30; i++) {if(buttonstate){};rainbow_loop();}
- for(int i=0; i<r*40; i++) {if(buttonstate){};random_burst();}
- for(int i=0; i<r*42; i++) {if(buttonstate){};color_bounce();}
- thisdelay = 40;
- for(int i=0; i<r*42; i++) {if(buttonstate){};color_bounceFADE();}
- for(int i=0; i<r*12; i++) {if(buttonstate){};ems_lightsONE();}
- for(int i=0; i<r*10; i++) {if(buttonstate){};ems_lightsALL();}
- thishue = 160; thissat = 50;
- for(int i=0; i<r*40; i++) {if(buttonstate){};flicker();}
- one_color_all(0,0,0); LEDS.show();
- thisdelay = 15; thishue = 0; thissat = 255;
- for(int i=0; i<r*50; i++) {if(buttonstate){};pulse_one_color_all();}
- for(int i=0; i<r*40; i++) {if(buttonstate){};pulse_one_color_all_rev();}
- thisdelay = 60; thishue = 180;
- for(int i=0; i<r*5; i++) {if(buttonstate){};fade_vertical();}
- random_red();
- thisdelay = 100;
- for(int i=0; i<r*5; i++) {if(buttonstate){};rule30();}
- thisdelay = 40;
- for(int i=0; i<r*8; i++) {if(buttonstate){};random_march();}
- thisdelay = 80;
- for(int i=0; i<r*5; i++) {if(buttonstate){};rwb_march();}
- one_color_all(0,0,0); ; LEDS.show();
- thisdelay = 60; thishue = 95;
- for(int i=0; i<r*15; i++) {if(buttonstate){};radiation();}
- for(int i=0; i<r*15; i++) {if(buttonstate){};color_loop_vardelay();}
- //for(int i=0; i<r*5; i++) {if(buttonstate){};white_temps();}
- thisdelay = 35; thishue = 180;
- for(int i=0; i<r; i++) {if(buttonstate){};sin_bright_wave();}
- thisdelay = 100; thishue = 100;
- for(int i=0; i<r*5; i++) {if(buttonstate){};pop_horizontal();}
- thisdelay = 100; thishue = 180;
- for(int i=0; i<r*4; i++) {if(buttonstate){};quad_bright_curve();}
- one_color_all(0,0,0); LEDS.show();
- for(int i=0; i<r*3; i++) {if(buttonstate){};flame();}
- thisdelay = 100; thishue = 175;
- for(int i=0; i<r*5; i++) {if(buttonstate){};pop_horizontal();}
- thisdelay = 50;
- for(int i=0; i<r*10; i++) {if(buttonstate){};pacman();}
- thisdelay = 50; thisstep = 15;
- for(int i=0; i<r*12; i++) {if(buttonstate){};rainbow_vertical();}
- thisdelay = 100;
- for(int i=0; i<r*3; i++) {if(buttonstate){};strip_march_ccw();}
- for(int i=0; i<r*3; i++) {if(buttonstate){};strip_march_cw();}
- demo_modeB();
- thisdelay = 5;
- for(int i=0; i<r*120; i++) {if(buttonstate){};new_rainbow_loop();}
- one_color_all(255,0,0); LEDS.show(); FastLED.delay(1200);
- one_color_all(0,255,0); LEDS.show(); FastLED.delay(1200);
- one_color_all(0,0,255); LEDS.show(); FastLED.delay(1200);
- one_color_all(255,255,0); LEDS.show(); FastLED.delay(1200);
- one_color_all(0,255,255); LEDS.show(); FastLED.delay(1200);
- one_color_all(255,0,255); LEDS.show(); FastLED.delay(1200);
- }
- void demo_modeB(){
- int r = 10;
- one_color_all(0,0,0); LEDS.show();
- thisdelay = 35;
- for(int i=0; i<r*10; i++) {random_color_pop();}
- for(int i=0; i<r/2; i++) {ems_lightsSTROBE();}
- thisdelay = 50;
- for(int i=0; i<r*10; i++) {rgb_propeller();}
- one_color_all(0,0,0); LEDS.show();
- thisdelay = 100; thishue = 0;
- for(int i=0; i<r*3; i++) {kitt();}
- one_color_all(0,0,0); LEDS.show();
- thisdelay = 30; thishue = 95;
- for(int i=0; i<r*25; i++) {matrix();}
- one_color_all(0,0,0); LEDS.show();
- }
- void change_mode(int newmode){
- thissat = 255;
- switch (newmode) {
- case 0: one_color_all(0,0,0); LEDS.show(); break; //---ALL OFF
- case 1: one_color_all(255,255,255); LEDS.show(); break; //---ALL ON
- case 2: thisdelay = 20; break; //---STRIP RAINBOW FADE
- case 3: thisdelay = 0; thisstep = 50; break; //---RAINBOW LOOP
- case 4: thisdelay = 20; break; //---RANDOM BURST
- case 5: thisdelay = 20; thishue = 0; // random(0,250); break; //---CYLON v1
- case 6: thisdelay = 40; thishue = random(0,250); break; //---CYLON v2
- case 7: thisdelay = 40; thishue = random(0,250); break; //---POLICE LIGHTS SINGLE
- case 8: thisdelay = 40; thishue = random(0,250); break; //---POLICE LIGHTS SOLID
- case 9: thishue = 160; thishue = random(0,250); break; //---STRIP FLICKER
- case 10: thisdelay = 10; thishue = random(0,250); break; //---PULSE COLOR BRIGHTNESS
- case 11: thisdelay = 10; thishue = random(0,250); break; //---PULSE COLOR SATURATION
- case 12: thisdelay = 60; thishue = random(0,250); break; //---VERTICAL SOMETHING
- case 13: thisdelay = 100;thishue = random(0,250); break; //---CELL AUTO - RULE 30 (RED)
- case 14: thisdelay = 70; thishue = random(0,250); break; //---MARCH RANDOM COLORS
- case 15: thisdelay = 100; thishue = random(0,250); break; //---MARCH RWB COLORS
- case 16: thisdelay = 0; thishue = random(0,250); break; //---RADIATION SYMBOL
- case 17: thisdelay = 60; thishue = random(0,250); break;
- case 18: thisdelay = 10; thishue = random(0,250);break;
- case 19: thisdelay = 35; thishue = random(0,250); break; //---SIN WAVE BRIGHTNESS
- case 20: thisdelay = 100; thishue = random(0,250); break; //---POP LEFT/RIGHT
- case 21: thisdelay = 100; thishue = random(0,250); break; //---QUADRATIC BRIGHTNESS CURVE
- case 22: thisdelay = 60; thishue = random(0,250); break;
- case 23: thisdelay = 50; thisstep = 15; thishue = random(0,250); break; //---VERITCAL RAINBOW
- case 24: thisdelay = 70; thishue = random(0,250); break; //---PACMAN
- case 25: thisdelay = 45; thishue = random(0,250); break; //---RANDOM COLOR POP
- case 26: thisdelay = 125; thishue = random(0,250); break; //---EMERGECNY STROBE
- case 27: thisdelay = 25; thishue = random(0,250); break; //---RGB PROPELLER
- case 28: thisdelay = 100; thishue = random(0,250); break; //---KITT
- case 29: thisdelay = 50; thishue = random(0,250); break; //---MATRIX RAIN
- case 50: thisdelay = 100; break; //---MARCH STRIP NOW CCW
- case 51: thisdelay = 100; break; //---MARCH STRIP NOW CCW
- case 88: thisdelay = 5; break; //---NEW RAINBOW LOOP
- case 101: one_color_all(255,0,0); LEDS.show(); break; //---ALL RED
- case 102: one_color_all(0,255,0); LEDS.show(); break; //---ALL GREEN
- case 103: one_color_all(0,0,255); LEDS.show(); break; //---ALL BLUE
- case 104: one_color_all(255,255,0); LEDS.show(); break; //---ALL COLOR X
- case 105: one_color_all(0,255,255); LEDS.show(); break; //---ALL COLOR Y
- case 106: one_color_all(255,0,255); LEDS.show(); break; //---ALL COLOR Z
- }
- bouncedirection = 0;
- one_color_all(0,0,0);
- ledMode = newmode;
- }
- //------------------SETUP------------------
- void setup()
- {
- Serial.begin(SERIAL_BAUDRATE); // SETUP HARDWARE SERIAL (USB)
- pinMode(pbIn, INPUT);
- attachInterrupt(pbIn, stateChange, CHANGE);
- LEDS.setBrightness(max_bright);
- //////////////////////////
- // FASTLEDS
- //////////////////////////
- time.every(45000, timer);
- //FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
- FastLED.addLeds<WS2812B, 2, GRB>(leds, NUM_LEDS);
- one_color_all(0,0,0); //-CLEAR STRIP
- LEDS.show();
- Serial.println("---SETUP COMPLETE---");
- }
- //------------------MAIN LOOP------------------
- void loop() {
- time.update();
- switch (ledMode) {
- case 999: break;
- case 2: rainbow_fade(); break;
- //case 2: ColorForest(); break; //for testing
- case 3: rainbow_loop(); break;
- case 4: ColorOcean(); break;
- case 5: ColorRandom(); break;
- case 6: color_bounceFADE(); break;
- case 7: ColorPalette(); break;
- case 8: ColorBW(); break;
- case 9: color_bounceFADE(); break;
- case 10: pulse_one_color_all(); break;
- case 11: ColorForest(); break;
- case 12: fade_vertical(); break;
- case 13: ColorForest(); break;
- case 14: random_color_pop(); break;
- case 15: ColorPalette(); break;
- case 16: rainbow_loop(); break;
- case 17: kitt(); break;
- case 18: pulse_one_color_all(); break;
- case 19: ColorRandom(); break;
- case 20: pop_horizontal(); break;
- case 21: ColorPG();break;
- case 22: color_loop_vardelay(); break;
- case 23: rainbow_vertical(); break;
- case 24: pop_horizontal(); break;
- case 25: random_color_pop(); break;
- case 26: ems_lightsSTROBE(); break;
- case 27: ColorLava(); break;
- case 28: kitt(); break;
- case 29: color_loop_vardelay();break;
- case 50: strip_march_ccw(); break;
- case 51: strip_march_cw(); break;
- case 88: new_rainbow_loop(); break;
- case 888: demo_modeA(); break;
- case 889: demo_modeB(); break;
- }
- ///////////////////////// SERIAL AND BLUETOOTH STUFF
- /*
- //---PROCESS HARDWARE SERIAL COMMANDS AND ARGS
- while (Serial.available() > 0) {
- Serial.println("HARDWARE AVAILABLE");
- inbyte = Serial.read();
- Serial.println(inbyte);
- switch(inbyte) {
- case 59: break; //---BREAK IF INBYTE = ';'
- case 108: //---"l" - SET SINGLE LED VALUE RGB
- thisindex = Serial.parseInt();
- thisRED = Serial.parseInt();
- thisGRN = Serial.parseInt();
- thisBLU = Serial.parseInt();
- if (ledMode != 999) {
- ledMode = 999;
- one_color_all(0,0,0);}
- leds[thisindex].setRGB( thisRED, thisGRN, thisBLU);
- break;
- case 118: //---"v" - SET SINGLE LED VALUE HSV
- thisindex = Serial.parseInt();
- thishue = Serial.parseInt();
- thissat = Serial.parseInt();
- //thisVAL = Serial.parseInt();
- if (ledMode != 999) {
- ledMode = 999;
- one_color_all(0,0,0);}
- leds[thisindex] = CHSV(thishue, thissat, 255);
- break;
- case 100: //---"d" - SET DELAY VAR
- thisarg = Serial.parseInt();
- thisdelay = thisarg;
- break;
- case 115: //---"s" - SET STEP VAR
- thisarg = Serial.parseInt();
- thisstep = thisarg;
- break;
- case 104: //---"h" - SET HUE VAR
- thisarg = Serial.parseInt();
- thishue = thisarg;
- break;
- case 116: //---"t" - SET SATURATION VAR
- thisarg = Serial.parseInt();
- thissat = thisarg;
- break;
- case 98: //---"b" - SET MAX BRIGHTNESS
- max_bright = Serial.parseInt();
- LEDS.setBrightness(max_bright);
- break;
- case 109: //---"m" - SET MODE
- thisarg = Serial.parseInt();
- Serial.println(thisarg);
- Serial.println("TEST MODE");
- change_mode(thisarg);
- break;
- case 99: //---"c" - CLEAR STRIP
- one_color_all(0,0,0);
- break;
- case 97: //---"a" - SET ALL TO ONE COLOR BY HSV 0-255
- thisarg = Serial.parseInt();
- one_color_allHSV(thisarg);
- break;
- case 122: //---"z" - COMMAND TO 'SHOW' LEDS
- LEDS.show();
- break;
- case 81: //---"Q" - COMMAND RETURN VERSION NUMBER
- Serial.print(VERSION_NUMBER);
- break;
- }
- }
- */
- /*
- //---PROCESS SOFTWARE SERIAL COMMANDS AND ARGS
- while (btSerial.available() > 0) {
- //Serial.println("BT AVAILABLE");
- inbyteB = btSerial.read();
- Serial.println(inbyteB);
- if (btSerial.overflow()){Serial.println("SoftwareSerial overflow!");}
- switch(inbyteB) {
- case 59: break; //---BREAK IF INBYTE = ';'
- case 108: //---"l" - SET SINGLE LED VALUE
- thisindex = btSerial.parseInt();
- thisRED = btSerial.parseInt();
- thisGRN = btSerial.parseInt();
- thisBLU = btSerial.parseInt();
- if (ledMode != 999) {
- ledMode = 999;
- one_color_all(0,0,0);}
- leds[thisindex].setRGB( thisRED, thisGRN, thisBLU);
- break;
- case 100: //---"d" - SET DELAY VAR
- thisarg = btSerial.parseInt();
- thisdelay = thisarg;
- Serial.println(thisdelay);
- break;
- case 115: //---"s" - SET STEP VAR
- thisarg = btSerial.parseInt();
- thisstep = thisarg;
- break;
- case 104: //---"h" - SET HUE VAR
- thisarg = btSerial.parseInt();
- thishue = thisarg;
- break;
- case 116: //---"t" - SET SATURATION VAR
- thisarg = btSerial.parseInt();
- thissat = thisarg;
- Serial.println(thisarg);
- break;
- case 98: //---"b" - SET MAX BRIGHTNESS
- max_bright = btSerial.parseInt();
- Serial.println(max_bright);
- LEDS.setBrightness(max_bright);
- break;
- case 109: //---"m" - SET MODE
- thisarg = btSerial.parseInt();
- Serial.println("M COMMAND");
- Serial.println(thisarg);
- change_mode(thisarg);
- break;
- case 99: //---"c" - CLEAR STRIP
- one_color_all(0,0,0);
- break;
- case 97: //---"a" - SET ALL TO ONE COLOR BY HSV 0-255
- thisarg = btSerial.parseInt();
- one_color_allHSV(thisarg);
- break;
- case 122: //---"z" - COMMAND TO 'SHOW' LEDS
- LEDS.show();
- //Serial.println("Z COMMAND");
- break;
- }
- }
- */
- //FastLED.delay(110);
- }
- void stateChange()
- {
- //Serial.println("Button Pressed");
- //delay(10);
- buttonstate = 1;
- ledMode++;
- //if (ledMode > 29) {ledMode=1;};
- //Serial.println("ledMode"); Serial.println(ledMode);
- }
- ////////////////// AUTO TIMER /////////////////////////////////////
- void timer()
- {
- Serial.println("TIMER ledMode is now:");Serial.println(newmode);
- newmode++;
- Serial.println(" NewMode is now:");Serial.println(newmode);
- if (newmode > 29) { newmode = 2; }
- change_mode(newmode);
- }
- ///////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment