Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <avr/wdt.h>
- #include <Wire.h>
- #include <RH_ASK.h>
- #include <SPI.h>
- #include "printf.h"
- #include <FastLED.h>
- RH_ASK driver(2400, 50, 49, 49, false);
- #define NUM_LEDS 120
- CRGB leds[NUM_LEDS];
- // Starting height, in meters, of the ball (strip length)
- #define NUM_BALLS 3 // Number of bouncing balls you want (recommend < 7, but 20 is fun in its own way)
- float h[NUM_BALLS] ;// An array of heights
- float vImpact0; // Impact velocity of the ball when it hits the ground if "dropped" from the top of the strip
- float vImpact[NUM_BALLS] ; // As time goes on the impact velocity will change, so make an array to store those values
- float tCycle[NUM_BALLS] ; // The time since the last time the ball struck the ground
- int pos[NUM_BALLS] ;
- int mirror[NUM_BALLS];// The integer position of the dot on the strip (LED index)
- long tLast[NUM_BALLS] ; // The clock time of the last ground strike
- float COR[NUM_BALLS] ; // Coefficient of Restitution (bounce damping)
- byte A = rand();
- byte B = rand();
- byte C = rand();
- byte D = rand();
- byte zZone = 0;
- unsigned int zSpeedA;
- byte zonePatternA;
- //LED Information
- struct fade {
- unsigned char r, g, b, f;
- };
- struct fade *lights;
- //zone pattern arras
- byte zonePattern[46];
- //xxxxxxxxxxxxxxxxxx
- //Chasing Programs
- //xxxxxxxxxxxxxxxxxx
- //Rainbow
- byte rainbowpattern[46] = {
- 0, 0, 0, 0, 0, 32, 32, 32, 32, 32, 64, 64, 64, 64, 64, 96, 96, 96, 96, 96, 128, 128, 128, 128, 128, 160, 160, 160, 160, 160, 160, 192, 192, 192, 192, 192, 224, 224, 224, 224, 224, 255, 255, 255, 255, 255};
- byte rainbowfadepattern[46] = {
- 0, 0, 8, 16, 24, 32, 32, 32, 40, 48, 56, 64, 64, 72, 78, 86, 96, 96, 96, 104, 112, 120, 128, 128, 128, 136, 144, 152, 160, 160, 160, 168, 176, 184, 192, 192, 200, 208, 216, 224, 224, 232, 240, 248, 255, 255};
- byte lazer[46] = {
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 100, 255, 100, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
- byte longstreakspattern[46] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 7, 7, 7, 30, 30, 30, 30, 60, 60, 60, 60, 120, 120, 120, 120, 180, 180, 180, 180, 255, 255, 255, 255};
- byte shortstreakspattern[46] = {
- 3, 7, 60, 120, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- byte diamondfadepattern[46] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 7, 15, 30, 45, 60, 80, 120, 140, 180, 255, 255, 180, 120, 80, 60, 45, 30, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- byte copspattern[46] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160};
- byte twocolorchasepattern[46] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0};
- byte colorchasepattern[46] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3};
- /* faders
- int fader[] = {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
- int faderoff[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- const char faderLength = 31;
- //xxxxxxxxxxxxxxxxxx
- //Patriotic Programs
- //xxxxxxxxxxxxxxxxxx
- //Patriotic One
- int patriotic1Red[] = {
- 255, 255, 255, 255, 255, 255, 0, 0, 0};
- int patriotic1Blue[] = {
- 244, 244, 244, 0, 0, 0, 255, 255, 255};
- int patriotic1Green[] = {
- 255, 255, 255, 0, 0, 0, 0, 0, 0};
- const char patriotic1Length = 9;
- */
- void patternShift(int colorr[], int colorb[], int colorg[], int arraySize);
- boolean zFlag;
- typedef void (*LEDfunctions) ();
- LEDfunctions functionsArray [43] =
- {
- spacing,
- off,
- custom,
- white,
- green,
- red,
- blue,
- yellow,
- orange,
- pink,
- purple,
- marine,
- grassgreen,
- rainbow,
- rainbowfade,
- longstreaks,
- shortstreaks,
- diamondfade,
- customlazer,
- cops,
- cops1,
- twocolorchase,
- bouncing,
- strobingC,
- strobingW,
- rainbowFade,
- redblueFade,
- redgreenFade,
- purpleorangeFade,
- aquaFade,
- skyFade,
- everyFade,
- veryslowFade,
- twinkle,
- randomWalk,
- colorrandomWalk,
- colorChase,
- colorWhipe,
- rainDrop,
- colorslide,
- patrioticTwinkle,
- christmasTwinkle,
- patriotic1,
- };
- byte programInformation[8];
- byte program = 0;
- byte hue = 1;
- byte saturation = 2;
- byte value = 3;
- byte special = 4;
- byte speed = 5;
- byte zone = 6;
- byte reply = 7;
- unsigned long zstart = millis();
- unsigned long flasherstart = millis();
- unsigned long flasherstart1 = millis();
- byte flasherinterval = 135;
- byte oldProgram;
- unsigned int colorSF;
- byte programA = 0;
- boolean once;
- CHSV colorHSV;
- unsigned long zSpeed;
- byte DisplaySpeed;
- bool onceA;
- void loop()
- {
- Receive();
- if (onceA == 1) {
- onceA = 0;
- speak();
- }
- functionsArray [programA] ();
- once = 0;
- zoneIncrementers();
- FastLED.show();
- }
- void Receive() {
- uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
- uint8_t buflen = sizeof(buf);
- if (driver.recv(buf, &buflen)) // Non-blocking
- {
- digitalWrite(13, HIGH);
- int i;
- // Message with a good checksum received, dump it.
- Serial.println("");
- driver.printBuffer("Got:", buf, buflen);
- memcpy(programInformation, buf, 8);
- onceA = 1;
- digitalWrite(13, LOW);
- }
- }
- void speedConversion() {
- if (DisplaySpeed == 0) {
- zSpeed = 5000;
- }
- else if(DisplaySpeed == 1){
- zSpeed = 1000;
- }
- else if(DisplaySpeed == 2){
- zSpeed = 925;
- }
- else if(DisplaySpeed == 3){
- zSpeed = 775;
- }
- else if(DisplaySpeed == 4){
- zSpeed = 625;
- }
- else if(DisplaySpeed == 5){
- zSpeed = 400;
- }
- else if(DisplaySpeed == 6){
- zSpeed = 275;
- }
- else if(DisplaySpeed == 7){
- zSpeed = 150;
- }
- else if(DisplaySpeed == 8){
- zSpeed = 70;
- }
- else if(DisplaySpeed == 9){
- zSpeed = 35;
- }
- else if(DisplaySpeed == 10){
- zSpeed = 15;
- }
- }
- void speak() {
- Serial.println("begin");
- Serial.println(programInformation[zone]);
- Serial.println(programInformation[program]);
- Serial.println(programInformation[hue]);
- Serial.println(programInformation[saturation]);
- Serial.println(programInformation[value]);
- Serial.println(programInformation[speed]);
- Serial.println(programInformation[special]);
- Serial.println("end");
- if(programInformation[zone] == 0){
- // reset();
- }
- if(programInformation[zone] == 1){
- programA = programInformation[program];
- colorHSV.h = programInformation[hue];
- colorHSV.s = programInformation[saturation];
- colorHSV.v = programInformation[value];
- DisplaySpeed = programInformation[speed];
- colorSF = programInformation[special];
- speedConversion();
- once = 1;
- Serial.print("Values Successfull Assigned");
- }
- }
- int reset(void)
- {
- wdt_enable(WDTO_8S);
- while(1) {};
- }
- void setup() {
- pinMode(13, OUTPUT);
- FastLED.addLeds<LPD8806, 45, 43, BRG>(leds, NUM_LEDS);
- Serial.begin(57600);
- Serial.println("");
- if (!driver.init()) {
- Serial.println("init failed");
- }
- Serial.println("Mode: Receiver 1");
- Serial.println("ready to go");
- if (NUM_LEDS < 50) {
- vImpact0 = 3.75;
- }
- else if (NUM_LEDS < 150) {
- vImpact0 = 4.25;
- }
- else {
- vImpact0 = 5.25;
- }
- for (int i = 0 ; i < NUM_BALLS ; i++) { // Initialize variables
- tLast[i] = millis();
- h[i] = 3;
- pos[i] = 0; // Balls start on the ground
- vImpact[i] = vImpact0; // And "pop" up at vImpact0
- tCycle[i] = 0;
- COR[i] = 0.90 - float(i) / pow(NUM_BALLS, 2);
- }
- randomSeed(analogRead(A1));
- // BBOUNCING BOUCING BOUCNING
- }
- void spacing() { //does nothing, so that the first array value for the color programs doesn't equal zero
- }
- void patternShift(byte zone[]) {
- byte tempZone;
- for (byte i=0; i<45; i++)
- {
- tempZone = zone[45];
- zone[45] = zone[i];
- zone[i] = tempZone;
- }
- }
- void zoneIncrementers() {
- unsigned long z = millis();
- if(z - zstart >= zSpeed && zSpeed != 5000){
- patternShift(zonePattern);
- zFlag = !zFlag;
- zstart = z;
- }
- }
- void FunctionForEachPixel (byte icNumber, byte index)
- {
- zZone = 0;
- zonePatternA = zonePattern[index];
- }
- void off() {
- for (byte i = 0; i < NUM_LEDS; i++) {
- leds[i].setRGB( 0, 0, 0);
- }
- }
- void custom() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = colorHSV;
- }
- }
- void white() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].setHSV( 255, 0, 255);
- }
- }
- void green() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].setRGB( 0, 255, 0);
- }
- }
- void red() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].setRGB( 255, 0, 0);
- }
- }
- void blue() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].setRGB( 0, 0, 255);
- }
- }
- void yellow() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].setHSV(64, 255, 255);
- }
- }
- void orange() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].setRGB( 255, 40, 0);
- }
- }
- void pink() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].setRGB( 255, 0, 40);
- }
- }
- void purple() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].setRGB( 85, 0, 85);
- }
- }
- void marine() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].setRGB( 0, 255, 200);
- }
- }
- void grassgreen() {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].setRGB( 60, 255, 0);
- }
- }
- void rainbow() {
- if (once) {
- Serial.println("yes");
- memcpy(zonePattern, rainbowpattern, 46);
- }
- for (int i = 0 ; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- leds[i] = CHSV(zonePatternA, 255, 255);
- }
- }
- void rainbowfade() {
- if (once) {
- Serial.println("one mo gin");
- memcpy(zonePattern, rainbowfadepattern, 46);
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- leds[i] = CHSV(zonePatternA, 255, 255);
- }
- }
- void longstreaks() {
- if (once) {
- memcpy(zonePattern, longstreakspattern, 46);
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- leds[i] = colorHSV;
- leds[i].nscale8_video(zonePatternA);
- }
- }
- void shortstreaks() {
- if (once) {
- memcpy(zonePattern, shortstreakspattern, 46);
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- leds[i] = colorHSV;
- leds[i].nscale8_video(zonePatternA);
- }
- }
- void diamondfade() {
- if (once) {
- memcpy(zonePattern, diamondfadepattern, 46);
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- leds[i] = colorHSV;
- leds[i].nscale8_video(zonePatternA);
- }
- }
- void customlazer() {
- if (once) {
- memcpy(zonePattern, lazer, 46);
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- leds[i] = colorHSV;
- leds[i].nscale8_video(zonePatternA);
- }
- }
- void cops() {
- if (once) {
- memcpy(zonePattern, copspattern, 46);
- }
- unsigned long flasherTime = millis();
- static boolean flashflag = 0;
- int color = 0;
- int color2 = 0;
- byte blinkA = (NUM_LEDS / 4) - 2;
- byte blinkB = (NUM_LEDS / 2) + blinkA;
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- leds[i] = CHSV(zonePatternA, 255, 255);
- if (flasherTime - flasherstart >= flasherinterval) {
- flashflag = ! flashflag;
- flasherstart = flasherTime;
- }
- if (flashflag == 0) {
- color = 255;
- color2 = 0;
- }
- else {
- color = 0;
- color2 = 255;
- }
- if (i <= NUM_LEDS) {
- if (color == 255) {
- leds[blinkA].setRGB(color, color, color);
- leds[blinkA + 1].setRGB(color, color, color);
- leds[blinkA + 2].setRGB(color, color, color);
- leds[blinkA + 3].setRGB(color, color, color);
- if (NUM_LEDS > 60) {
- leds[blinkA - 1].setRGB(color, color, color);
- leds[blinkA - 2].setRGB(color, color, color);
- leds[blinkA - 3].setRGB(color, color, color);
- leds[blinkA - 4].setRGB(color, color, color);
- }
- if (NUM_LEDS > 100) {
- leds[blinkA - 5].setRGB(color, color, color);
- leds[blinkA - 6].setRGB(color, color, color);
- leds[blinkA + 4].setRGB(color, color, color);
- leds[blinkA + 5].setRGB(color, color, color);
- }
- if (NUM_LEDS > 150) {
- leds[blinkA - 7].setRGB(color, color, color);
- leds[blinkA - 8].setRGB(color, color, color);
- leds[blinkA + 6].setRGB(color, color, color);
- leds[blinkA + 7].setRGB(color, color, color);
- }
- if (NUM_LEDS > 200) {
- leds[blinkA - 9].setRGB(color, color, color);
- leds[blinkA - 10].setRGB(color, color, color);
- leds[blinkA + 8].setRGB(color, color, color);
- leds[blinkA + 9].setRGB(color, color, color);
- }
- }
- if (color2 == 255) {
- leds[blinkB].setRGB(color2, color2, color2);
- leds[blinkB + 1].setRGB(color2, color2, color2);
- leds[blinkB + 2].setRGB(color2, color2, color2);
- leds[blinkB + 3].setRGB(color2, color2, color2);
- if (NUM_LEDS > 60) {
- leds[blinkB - 1].setRGB(color2, color2, color2);
- leds[blinkB - 2].setRGB(color2, color2, color2);
- leds[blinkB - 3].setRGB(color2, color2, color2);
- leds[blinkB - 4].setRGB(color2, color2, color2);
- }
- if (NUM_LEDS > 100) {
- leds[blinkB - 5].setRGB(color2, color2, color2);
- leds[blinkB - 6].setRGB(color2, color2, color2);
- leds[blinkB + 4].setRGB(color2, color2, color2);
- leds[blinkB + 5].setRGB(color2, color2, color2);
- }
- if (NUM_LEDS > 150) {
- leds[blinkB - 7].setRGB(color2, color2, color2);
- leds[blinkB - 8].setRGB(color2, color2, color2);
- leds[blinkB + 6].setRGB(color2, color2, color2);
- leds[blinkB + 7].setRGB(color2, color2, color2);
- }
- if (NUM_LEDS > 200) {
- leds[blinkB - 9].setRGB(color2, color2, color2);
- leds[blinkB - 10].setRGB(color2, color2, color2);
- leds[blinkB + 8].setRGB(color2, color2, color2);
- leds[blinkB + 9].setRGB(color2, color2, color2);
- }
- }
- }
- }
- }
- void cops1() {
- unsigned long flasherTime1 = millis();
- static boolean flashflagg;
- int ca = 255;
- int cb = 255;
- byte half = NUM_LEDS / 2;
- if (flasherTime1 - flasherstart1 >= zSpeed) {
- flashflagg = ! flashflagg;
- flasherstart1 = flasherTime1;
- }
- if (flashflagg == 0) {
- ca = 255;
- cb = 0;
- }
- else {
- ca = 0;
- cb = 255;
- }
- for (int j = 0; j <= half; j++) {
- leds[j].setRGB(ca, 0, cb);
- }
- for (int h = half + 1; h < NUM_LEDS; h++) {
- leds[h].setRGB(cb, 0, ca);
- }
- }
- void twocolorchase() {
- if (once) {
- memcpy(zonePattern, twocolorchasepattern, 46);
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- CHSV twocolorchaseHSV = colorHSV;
- if (zonePatternA == 0) {
- leds[i].setHSV(twocolorchaseHSV.h - 64, twocolorchaseHSV.s, twocolorchaseHSV.v - 30);
- }
- if (zonePatternA == 1) {
- leds[i].setHSV(twocolorchaseHSV.h - 25, twocolorchaseHSV.s, twocolorchaseHSV.v - 30);
- }
- if (zonePatternA == 2) {
- leds[i].setHSV(twocolorchaseHSV.h, twocolorchaseHSV.s, twocolorchaseHSV.v);
- }
- }
- }
- void bouncing() {
- if (once) {
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CHSV(64, 128, 16);
- }
- }
- byte color1;
- byte color2;
- byte color3;
- //Then off for the next loop around
- for (int i = 0; i < NUM_BALLS; i++) {
- if ((pos[i] - 4) <= NUM_LEDS - 1 && (pos[i] - 4) >= 0) {
- leds[pos[i] - 4] = CHSV(64, 128, 16);
- }
- if ((pos[i] - 3) <= NUM_LEDS - 1 && (pos[i] - 3) >= 0) {
- leds[pos[i] - 3] = CHSV(64, 128, 16);
- }
- if ((pos[i] - 2) <= NUM_LEDS - 1 && (pos[i] - 2) >= 0) {
- leds[pos[i] - 2] = CHSV(64, 128, 16);
- }
- if ((pos[i] - 1) <= NUM_LEDS - 1 && (pos[i] - 1) >= 0) {
- leds[pos[i] - 1] = CHSV(64, 128, 16);
- }
- if ((pos[i]) <= NUM_LEDS - 1 && pos[i] >= 0) {
- leds[pos[i]] = CHSV(64, 128, 16);
- }
- if (NUM_LEDS > 100) {
- mirror[i] = NUM_LEDS - pos[i];
- if ((mirror[i] - 4) <= NUM_LEDS - 1 && (mirror[i] - 4) >= 0) {
- leds[mirror[i] - 4] = CHSV(64, 128, 16);
- }
- if ((mirror[i] - 3) <= NUM_LEDS - 1 && (mirror[i] - 3) >= 0) {
- leds[mirror[i] - 3] = CHSV(64, 128, 16);
- }
- if ((mirror[i] - 2) <= NUM_LEDS - 1 && (mirror[i] - 2) >= 0) {
- leds[mirror[i] - 2] = CHSV(64, 128, 16);
- }
- if ((mirror[i] - 1) <= NUM_LEDS - 1 && (mirror[i] - 1) >= 0) {
- leds[mirror[i] - 1] = CHSV(64, 128, 16);
- }
- if ((mirror[i]) <= NUM_LEDS - 1 && mirror[i] >= 0) {
- leds[mirror[i]] = CHSV(64, 128, 16);
- }
- }
- }
- for (int i = 0; i < NUM_BALLS ; i++) {
- tCycle[i] = millis() - tLast[i] ; // Calculate the time since the last time the ball was on the ground
- // A little kinematics equation calculates positon as a function of time, acceleration (gravity) and intial velocity
- h[i] = 0.5 * -2.81 * pow( tCycle[i] / 1000 , 2.0 ) + vImpact[i] * tCycle[i] / 1000;
- if ( h[i] < 0 ) {
- h[i] = 0; // If the ball crossed the threshold of the "ground," put it back on the ground
- vImpact[i] = COR[i] * vImpact[i]; // and recalculate its new upward velocity as it's old velocity * COR
- tLast[i] = millis();
- if ( vImpact[i] < 0.03 ) vImpact[i] = vImpact0; // If the ball is barely moving, "pop" it back up at vImpact0
- }
- pos[i] = 0 + (round( h[i] * (55) / 3)); // Map "h" to a "pos" integer index position on the LED strip
- }
- //Choose color of LEDs, then the "pos" LED on
- for (int i = 0 ; i < NUM_BALLS; i++) {
- byte color = 0;
- if (i == 0) {
- color = 0;
- }
- if (i == 1) {
- color = 106;
- }
- if (i == 2) {
- color = 149;
- }
- if ((pos[i] - 4) <= NUM_LEDS - 1 && (pos[i] - 4) >= 0) {
- leds[pos[i] - 4] = CHSV(colorHSV.h - color, 255, 100);
- }
- if ((pos[i] - 3) <= NUM_LEDS - 1 && (pos[i] - 3) >= 0) {
- leds[pos[i] - 3] = CHSV(colorHSV.h - color, 255, 160);
- }
- if ((pos[i] - 2) <= NUM_LEDS - 1 && (pos[i] - 2) >= 0) {
- leds[pos[i] - 2] = CHSV(colorHSV.h - color, 255, 255);
- }
- if ((pos[i] - 1) <= NUM_LEDS - 1 && (pos[i] - 1) >= 0) {
- leds[pos[i] - 1] = CHSV(colorHSV.h - color, 255, 160);
- }
- if ((pos[i]) <= NUM_LEDS - 1 && pos[i] >= 0) {
- leds[pos[i]] = CHSV(colorHSV.h - color, 255, 100);
- }
- if (NUM_LEDS > 100) {
- if (i == 0) {
- color = 106;
- }
- if (i == 1) {
- color = 149;
- }
- if (i == 2) {
- color = 0;
- }
- mirror[i] = NUM_LEDS - pos[i];
- if ((mirror[i] - 4) <= NUM_LEDS - 1 && (mirror[i] - 4) >= 0) {
- leds[mirror[i] - 4] = CHSV(colorHSV.h - color, 255, 100);
- }
- if ((mirror[i] - 3) <= NUM_LEDS - 1 && (mirror[i] - 3) >= 0) {
- leds[mirror[i] - 3] = CHSV(colorHSV.h - color, 255, 160);
- }
- if ((mirror[i] - 2) <= NUM_LEDS - 1 && (mirror[i] - 2) >= 0) {
- leds[mirror[i] - 2] = CHSV(colorHSV.h - color, 255, 255);
- }
- if ((mirror[i] - 1) <= NUM_LEDS - 1 && (mirror[i] - 1) >= 0) {
- leds[mirror[i] - 1] = CHSV(colorHSV.h - color, 255, 160);
- }
- if ((mirror[i]) <= NUM_LEDS - 1 && mirror[i] >= 0) {
- leds[mirror[i]] = CHSV(colorHSV.h - color, 255, 100);
- }
- }
- }
- }
- void strobingC() {
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- leds[i] = CHSV(colorHSV.h, colorHSV.s, colorHSV.v * zFlag);
- }
- }
- void strobingW() {
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- leds[i] = CHSV(0, 0, 255 * zFlag);
- }
- }
- void rainbowFade() {
- static boolean justonce;
- static byte color;
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- if (zFlag == 1 && justonce == 1) {
- color = color++;
- if (color > 255) {
- color = 0;
- }
- justonce = 0;
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- leds[i] = CHSV(color, 255, 255);
- }
- }
- void redblueFade() {
- static boolean justonce;
- static byte color = 256;
- static int adjuster = -1;
- static byte count;
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- if (zFlag == 1 && justonce == 1) {
- if (adjuster < 3) {
- color = color + (2 * adjuster);
- if (color < 160 && color > 100) {
- color = 160;
- adjuster = 4;
- count = 0;
- }
- if (color < 3) {
- color = 256;
- adjuster = 3;
- count = 0;
- }
- }
- if (adjuster > 2) {
- count = count++;
- if (count > 40 && adjuster == 3) {
- count = 0;
- adjuster = -1;
- }
- if (count > 40 && adjuster == 4) {
- count = 0;
- adjuster = 1;
- }
- }
- justonce = 0;
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- leds[i] = CHSV(color, 255, 255);
- }
- }
- void redgreenFade() {
- static boolean justonce;
- static byte color = 0;
- static int adjuster = 1;
- static byte count;
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- if (zFlag == 1 && justonce == 1) {
- if (adjuster < 3) {
- color = color + (2 * adjuster);
- if (color > 96 && color < 200) {
- color = 96;
- adjuster = 4;
- count = 0;
- }
- if (color < 0 || color > 200) {
- color = 0;
- adjuster = 3;
- count = 0;
- }
- }
- if (adjuster > 2) {
- count = count++;
- if (count > 40 && adjuster == 3) {
- count = 0;
- adjuster = 1;
- }
- if (count > 40 && adjuster == 4) {
- count = 0;
- adjuster = -1;
- }
- }
- justonce = 0;
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- leds[i] = CHSV(color, 255, 255);
- }
- }
- void purpleorangeFade() {
- static boolean justonce;
- static byte color = 210;
- static int adjuster = 1;
- static byte count;
- static byte ccount;
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- if (zFlag == 1 && justonce == 1) {
- if (adjuster < 3) {
- ccount++;
- if (ccount > 2) {
- color = color + adjuster;
- ccount == 0;
- }
- if (color > 9 && color < 210) {
- adjuster = 3;
- }
- }
- if (adjuster > 2) {
- count++;
- if (count > 75 && adjuster == 3) {
- count = 0;
- if (color > 9 && color < 50) {
- adjuster = -1;
- color = 9;
- }
- if (color < 210 && color > 50) {
- adjuster = 1;
- color = 210;
- }
- }
- }
- justonce = 0;
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- leds[i] = CHSV(color, 255, 255);
- }
- }
- void aquaFade() {
- static boolean justonce;
- static byte color = 100;
- static int adjuster = 1;
- static byte count;
- static byte ccount;
- static int sAdjuster = -10;
- static int saturate = 255;
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- if (zFlag == 1 && justonce == 1) {
- if (adjuster < 3) {
- ccount++;
- if (ccount > 2) {
- color = color + adjuster;
- ccount == 0;
- }
- if (color > 150 || color < 100) {
- adjuster = 3;
- }
- }
- if (adjuster > 2) {
- count++;
- if (adjuster == 3) {
- if (color > 150) {
- adjuster = 4;
- color = 150;
- }
- if (color < 100 && count > 75) {
- count = 0;
- adjuster = 1;
- color = 100;
- }
- }
- }
- if (adjuster == 4) {
- saturate = saturate + sAdjuster;
- if (saturate < 50) {
- sAdjuster = 10;
- saturate = 50;
- }
- else if (saturate > 255) {
- sAdjuster = -10;
- saturate = 255;
- adjuster = -1;
- }
- }
- justonce = 0;
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- leds[i] = CHSV(color, saturate, 255);
- }
- }
- void skyFade() {
- static boolean justonce;
- static byte color = 130;
- static int adjuster = -1;
- static byte ccount;
- static int sAdjuster = -10;
- static int saturate = 255;
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- if (zFlag == 1 && justonce == 1) {
- if (adjuster < 3) {
- ccount++;
- if (ccount > 2) {
- color = color + adjuster;
- ccount == 0;
- }
- if (color > 180 || color < 130) {
- adjuster = 3;
- }
- }
- if (adjuster == 3) {
- if (color > 180) {
- adjuster = 4;
- color = 180;
- }
- if (color < 130) {
- adjuster = 4;
- color = 130;
- }
- }
- if (adjuster == 4) {
- saturate = saturate + sAdjuster;
- if (saturate < 100) {
- sAdjuster = 10;
- saturate = 100;
- }
- else if (saturate > 255) {
- sAdjuster = -10;
- saturate = 255;
- if (color == 180) {
- adjuster = -1;
- }
- if (color == 130) {
- adjuster = 1;
- }
- }
- }
- justonce = 0;
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- leds[i] = CHSV(color, saturate, 255);
- }
- }
- void everyFade() {
- static boolean justonce;
- static byte color = 0;
- static byte saturation = 255;
- static byte value = 100;
- static int adjuster = 1;
- static byte up = 0;
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- if (zFlag == 1 && justonce == 1) {
- if (up == 0) {
- color = color + adjuster;
- if (color == 255) {
- if (value < 255) {
- value = value + adjuster;
- }
- if (value == 255) {
- saturation = saturation - adjuster;
- if (saturation == 100) {
- up = 1;
- }
- }
- }
- }
- if (up == 1) {
- color = color - adjuster;
- if (color == 255) {
- if (saturation < 255) {
- saturation = saturation + adjuster;
- }
- if (saturation == 255) {
- value = value - adjuster;
- if (value == 100) {
- up = 1;
- }
- }
- }
- }
- justonce = 0;
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- leds[i] = CHSV(color, saturation, value);
- }
- }
- void veryslowFade() {
- static boolean justonce;
- if (once) {
- colorHSV.h = random(0, 255);
- zSpeed = 900000;
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- if (zFlag == 1 && justonce == 1) {
- colorHSV.h++;
- justonce = 0;
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- leds[i] = CHSV(colorHSV.h, 255, 255);
- }
- }
- void twinkle() {
- int ranamount = 250; // The higher the number, lowers the chance for a pixel to light up. // Standard delay value in milliseconds.
- uint8_t fadeval = 255; // Fade rate
- //if (ranamount >NUM_LEDS) ranamount = NUM_LEDS; // Make sure we're at least utilizing ALL the LED's.
- int idex = random16(0, ranamount);
- if (idex < NUM_LEDS) { // Only the lowest probability twinkles will do.
- leds[idex] = random(); // The idex LED is set to a random 32 bit value
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- leds[i].nscale8(fadeval); // Go through the array and reduce each RGB value by a percentage.
- }
- }
- void randomWalk() {
- static boolean justonce;
- static boolean resetflag;
- static int center;
- static int newpos = 999;
- static byte color;
- int adjuster;
- byte randoms;
- if (once) {
- resetflag = 1;
- zFlag = 1;
- justonce = 1;
- }
- center = (NUM_LEDS / 2) - 6;
- randoms = rand();
- if (randoms < 128) {
- adjuster = -1;
- }
- else adjuster = 1;
- if (zFlag == 1 && justonce == 1) {
- justonce = 0;
- if (resetflag == 1) {
- newpos = center ;
- color = rand();
- resetflag = 0;
- }
- else {
- color = color + 1;
- newpos = newpos + adjuster ;
- }
- if ((newpos) < 0 || (newpos - 6) > NUM_LEDS ) {
- resetflag = 1;
- }
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CHSV(color - 90, 255, 50);
- }
- if (NUM_LEDS > 100) {
- if ((newpos - 9) < NUM_LEDS && (newpos - 9) >= 0) {
- leds[newpos - 9] = CHSV(color, 255, 100);
- }
- if ((newpos - 8) < NUM_LEDS && (newpos - 8) >= 0) {
- leds[newpos - 8] = CHSV(color, 255, 140);
- }
- if ((newpos - 7) < NUM_LEDS && (newpos - 7) >= 0) {
- leds[newpos - 7] = CHSV(color, 255, 170);
- }
- if ((newpos - 6) < NUM_LEDS && (newpos - 6) >= 0) {
- leds[newpos - 6] = CHSV(color, 255, 190);
- }
- if (newpos - 5 < NUM_LEDS && newpos - 5 >= 0) {
- leds[newpos - 5] = CHSV(color, 255, 255);
- }
- if ((newpos - 4) < NUM_LEDS && (newpos - 4) >= 0) {
- leds[newpos - 4] = CHSV(color, 255, 255);
- }
- if ((newpos - 3) < NUM_LEDS && (newpos - 3) >= 0) {
- leds[newpos - 3] = CHSV(color, 255, 190);
- }
- if ((newpos - 2) < NUM_LEDS && (newpos - 2) >= 0) {
- leds[newpos - 2] = CHSV(color, 255, 170);
- }
- if ((newpos - 1) < NUM_LEDS && (newpos - 1) >= 0) {
- leds[newpos - 1] = CHSV(color, 255, 140);
- }
- if (newpos < NUM_LEDS && newpos >= 0) {
- leds[newpos] = CHSV(color, 255, 100);
- }
- }
- else {
- if ((newpos - 4) < NUM_LEDS && (newpos - 4) >= 0) {
- leds[newpos - 4] = CHSV(color, 255, 100);
- }
- if ((newpos - 3) < NUM_LEDS && (newpos - 3) >= 0) {
- leds[newpos - 3] = CHSV(color, 255, 160);
- }
- if ((newpos - 2) < NUM_LEDS && (newpos - 2) >= 0) {
- leds[newpos - 2] = CHSV(color, 255, 255);
- }
- if ((newpos - 1) < NUM_LEDS && (newpos - 1) >= 0) {
- leds[newpos - 1] = CHSV(color, 255, 160);
- }
- if (newpos < NUM_LEDS && newpos >= 0) {
- leds[newpos] = CHSV(color, 255, 100);
- }
- }
- }
- void colorrandomWalk() {
- static boolean justonce;
- static boolean resetflag;
- static int center;
- static int newpos = 999;
- static byte color;
- int adjuster;
- byte randoms;
- if (once) {
- resetflag = 1;
- zFlag = 1;
- justonce = 1;
- }
- center = (NUM_LEDS / 2) - 6;
- randoms = rand();
- if (randoms < 128) {
- adjuster = -1;
- }
- else adjuster = 1;
- if (zFlag == 1 && justonce == 1) {
- justonce = 0;
- if (resetflag == 1) {
- newpos = center ;
- color = colorHSV.h - 90;
- resetflag = 0;
- }
- else {
- newpos = newpos + adjuster ;
- }
- if ((newpos) < 0 || (newpos - 6) > NUM_LEDS ) {
- resetflag = 1;
- }
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CHSV(color, 255, 50);
- }
- if (NUM_LEDS > 100) {
- if ((newpos - 9) < NUM_LEDS && (newpos - 9) >= 0) {
- leds[newpos - 9] = CHSV(colorHSV.h, 255, 100);
- }
- if ((newpos - 8) < NUM_LEDS && (newpos - 8) >= 0) {
- leds[newpos - 8] = CHSV(colorHSV.h, 255, 140);
- }
- if ((newpos - 7) < NUM_LEDS && (newpos - 7) >= 0) {
- leds[newpos - 7] = CHSV(colorHSV.h, 255, 170);
- }
- if ((newpos - 6) < NUM_LEDS && (newpos - 6) >= 0) {
- leds[newpos - 6] = CHSV(colorHSV.h, 255, 190);
- }
- if (newpos - 5 < NUM_LEDS && newpos - 5 >= 0) {
- leds[newpos - 5] = CHSV(colorHSV.h, 255, 255);
- }
- if ((newpos - 4) < NUM_LEDS && (newpos - 4) >= 0) {
- leds[newpos - 4] = CHSV(colorHSV.h, 255, 255);
- }
- if ((newpos - 3) < NUM_LEDS && (newpos - 3) >= 0) {
- leds[newpos - 3] = CHSV(colorHSV.h, 255, 190);
- }
- if ((newpos - 2) < NUM_LEDS && (newpos - 2) >= 0) {
- leds[newpos - 2] = CHSV(colorHSV.h, 255, 170);
- }
- if ((newpos - 1) < NUM_LEDS && (newpos - 1) >= 0) {
- leds[newpos - 1] = CHSV(colorHSV.h, 255, 140);
- }
- if (newpos < NUM_LEDS && newpos >= 0) {
- leds[newpos] = CHSV(colorHSV.h, 255, 100);
- }
- }
- else {
- if ((newpos - 4) < NUM_LEDS && (newpos - 4) >= 0) {
- leds[newpos - 4] = CHSV(colorHSV.h, 255, 100);
- }
- if ((newpos - 3) < NUM_LEDS && (newpos - 3) >= 0) {
- leds[newpos - 3] = CHSV(colorHSV.h, 255, 160);
- }
- if ((newpos - 2) < NUM_LEDS && (newpos - 2) >= 0) {
- leds[newpos - 2] = CHSV(colorHSV.h, 255, 255);
- }
- if ((newpos - 1) < NUM_LEDS && (newpos - 1) >= 0) {
- leds[newpos - 1] = CHSV(colorHSV.h, 255, 160);
- }
- if (newpos < NUM_LEDS && newpos >= 0) {
- leds[newpos] = CHSV(colorHSV.h, 255, 100);
- }
- }
- }
- void specialrandomWalk() {
- static boolean justonce;
- static boolean resetflag;
- static int center;
- static int newPos = 999;
- static byte color;
- int adjuster;
- byte randoms;
- if (once) {
- resetflag = 1;
- zFlag = 1;
- justonce = 1;
- }
- center = (NUM_LEDS / 2) - 6;
- randoms = rand();
- if (randoms < 128) {
- adjuster = -1;
- }
- else adjuster = 1;
- for (int i = 0; i < NUM_LEDS; i++) {
- FunctionForEachPixel (i, 1);
- }
- if (zFlag == 1 && justonce == 1) {
- justonce = 0;
- if (resetflag == 1) {
- newPos = center;
- if (randoms < 128) {
- if (colorSF == 0) color = 96;
- if (colorSF == 160) color = 0;
- if (colorSF == 17) color = 210;
- }
- else {
- if (colorSF == 0) {
- color = colorSF;
- colorSF = 96;
- }
- if (colorSF == 160) {
- color = colorSF;
- colorSF = 0;
- }
- if (colorSF == 17) {
- color = colorSF;
- colorSF = 210;
- }
- }
- resetflag = 0;
- }
- else {
- newPos = newPos + adjuster;
- }
- if ((newPos) < -6 || newPos > NUM_LEDS) {
- resetflag = 1;
- if (colorSF == 160 || color == 160)
- {
- colorSF = 160;
- }
- }
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- leds[i] = CHSV(color, 255, 50);
- }
- if (newPos >= 0 && newPos <= NUM_LEDS) {
- leds[newPos] = CHSV(colorSF, 255, 50);
- }
- if (newPos + 1 >= 0 && newPos + 1 <= NUM_LEDS) {
- leds[newPos + 1] = CHSV(colorSF, 255, 100);
- }
- if (newPos + 2 >= 0 && newPos + 2 <= NUM_LEDS) {
- leds[newPos + 2] = CHSV(colorSF, 255, 175);
- }
- if (newPos + 3 >= 0 && newPos + 3 <= NUM_LEDS) {
- if (colorSF == 160 || color == 160) {
- leds[newPos + 3] = CHSV(0, 0, 255);
- }
- else leds[newPos + 3] = CHSV(colorSF, 255, 255);
- }
- if (newPos + 4 >= 0 && newPos + 4 <= NUM_LEDS) {
- leds[newPos + 4] = CHSV(colorSF, 255, 175);
- }
- if (newPos + 5 >= 0 && newPos + 5 <= NUM_LEDS) {
- leds[newPos + 5] = CHSV(colorSF, 255, 100);
- }
- if (newPos + 6 >= 0 && newPos + 6 <= NUM_LEDS) {
- leds[newPos + 6] = CHSV(colorSF, 255, 50 );
- }
- }
- void patrioticTwinkle() {
- zSpeed = 100;
- int ranamount = 1000; // The higher the number, lowers the chance for a pixel to light up. // Standard delay value in milliseconds.
- byte fadeval = 255; // Fade rate
- static byte color;
- static boolean justonce;
- //if (ranamount >NUM_LEDS) ranamount = NUM_LEDS; // Make sure we're at least utilizing ALL the LED's.
- int idex = random16(0, ranamount);
- if (idex < NUM_LEDS) { // Only the lowest probability twinkles will do.
- byte value = random(100, 255);
- byte saturation = random();
- if (color == 160) {
- color = 0;
- }
- else color = 160;
- if(idex < NUM_LEDS && idex > 0){
- leds[idex] = CHSV(color, saturation, value);
- }
- if((idex + 1) < NUM_LEDS && (idex + 1) > 0){
- leds[idex + 1] = CHSV(color, saturation, value);
- }
- }
- if (zFlag == 1 && justonce == 1) {
- justonce = 0;
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].nscale8(fadeval); // Go through the array and reduce each RGB value by a percentage.
- if((i + 1) < NUM_LEDS && (i + 1) > 0){
- leds[i + 1].nscale8(fadeval);
- }
- }
- } else if (zFlag == 0) {
- justonce = 1;
- }
- }
- void christmasTwinkle() {}
- /* zSpeed = 100;
- int ranamount = 1000; // The higher the number, lowers the chance for a pixel to light up. // Standard delay value in milliseconds.
- byte fadeval = 255; // Fade rate
- static byte color;
- static boolean justonce;
- // Make sure we're at least utilizing ALL the LED's.
- int idex = random16(0, ranamount);
- if (idex < NUM_LEDS) { // Only the lowest probability twinkles will do.
- byte value = random(100, 255);
- byte saturation = random();
- if (color == 0) {
- color = 96;
- }
- else color = 0;
- if(idex < NUM_LEDS && idex > 0){
- leds[idex] = CHSV(color, saturation, value);
- }
- if((idex + 1) < NUM_LEDS && (idex + 1) > 0){
- leds[idex + 1] = CHSV(color, saturation, value);
- }
- }
- if (zFlag == 1 && justonce == 1) {
- justonce = 0;
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].nscale8(fadeval); // Go through the array and reduce each RGB value by a percentage.
- if((i + 1) < NUM_LEDS && (i + 1) > 0){
- leds[i + 1].nscale8(fadeval);
- }
- }
- } else if (zFlag == 0) {
- justonce = 1;
- }
- }
- */
- void colorChase() {
- if (once) {
- memcpy(zonePattern, colorchasepattern, 46);
- once = 0;
- }
- byte color;
- byte color2;
- byte thecolor;
- byte thesaturation;
- static boolean justonce;
- static unsigned int count;
- static byte oldColor;
- static byte newColor;
- for (int i = 0; i < NUM_LEDS; i++) {
- const unsigned int idx = ( i % 46);
- FunctionForEachPixel (i, idx);
- int value = 100000 * 1 / (zSpeedA);
- Serial.println(value);
- if (zFlag == 1 && justonce == 1) {
- justonce = 0;
- count++;
- if (count > value || oldColor == newColor) {
- oldColor = newColor;
- newColor = oldColor + random(30, 200);
- count = 0;
- }
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- switch (colorSF) {
- case 1:
- thesaturation = 255;
- if (zonePatternA == 0 || zonePatternA == 1) {
- thecolor = 0;
- }
- else thecolor = 96;
- break;
- case 2:
- if (zonePattern == 0) {
- thecolor = 0;
- thesaturation = 255;
- }
- if (zonePatternA == 1 || zonePatternA == 2) {
- thecolor = 0;
- thesaturation = 0;
- }
- if (zonePatternA == 3) {
- thecolor = 160;
- thesaturation = 255;
- }
- break;
- case 3:
- thesaturation = 255;
- if (zonePatternA == 0 || zonePatternA == 1) {
- thecolor = 13;
- }
- else thecolor = 210;
- break;
- case 4:
- thesaturation = 255;
- if (zonePatternA == 0 || zonePatternA == 1) {
- thecolor = oldColor;
- }
- else {
- thecolor = newColor;
- }
- break;
- }
- leds[i] = CHSV(thecolor, thesaturation, 255);
- }
- }
- void colorslide() {
- if (once) {
- if (DisplaySpeed == 0) {
- zSpeed = 50;
- }
- else if (DisplaySpeed == 1) {
- zSpeed = 45;
- }
- else if (DisplaySpeed == 2) {
- zSpeed = 40;
- }
- else if (DisplaySpeed == 3) {
- zSpeed = 35;
- }
- else if (DisplaySpeed == 4) {
- zSpeed = 30;
- }
- else if (DisplaySpeed == 5) {
- zSpeed = 25;
- }
- else if (DisplaySpeed == 6) {
- zSpeed = 20;
- }
- else if (DisplaySpeed == 7) {
- zSpeed = 15;
- }
- else if (DisplaySpeed == 8) {
- zSpeed = 10;
- }
- else if (DisplaySpeed == 9) {
- zSpeed = 5;
- }
- else if (DisplaySpeed == 10) {
- zSpeed = 2;
- }
- }
- static boolean justonce;
- static boolean colorF;
- static byte count;
- static byte color;
- static byte saturation;
- static byte value0;
- for (int i = 0; i < NUM_LEDS; i++) {
- if (zFlag == 1 && justonce == 1) {
- if (count < NUM_LEDS && count >= 0) {
- count++;
- }
- else {
- count = 0;
- colorF = 1;
- }
- switch (colorSF) {
- case 1:
- if (colorF == 1) {
- colorF = 0;
- color = random();
- saturation = random(100, 255);
- value = random(100, 255);
- }
- case 2:
- if (colorF == 1) {
- colorF = 0;
- color = random();
- saturation = 255;
- value = 255;
- }
- break;
- case 3:
- saturation = 255;
- value = 255;
- color = random();
- break;
- case 4:
- if (colorF == 1) {
- colorF = 0;
- if (color == 0 && saturation == 255) {
- saturation = 0;
- value = 255;
- }
- else if (saturation == 0 && color == 0) {
- saturation = 255;
- value = 255;
- color = 160;
- }
- else if (color == 160) {
- color = 0;
- saturation = 255;
- value = 255;
- }
- else color = 0;
- }
- break;
- case 5:
- if (colorF == 1) {
- colorF = 0;
- saturation = 255;
- value = 255;
- if (color == 215) {
- color = 85;
- }
- else if (color == 85) {
- color = 139;
- }
- else if (color == 139) {
- color = 64;
- }
- else if (color == 64) {
- color = 215;
- }
- else color = 215;
- }
- break;
- case 6:
- if (colorF == 1) {
- colorF = 0;
- saturation = 255;
- value = 255;
- if (color == 200) {
- color = 16;
- }
- else if (color == 16) {
- color = 200;
- }
- else color = 200;
- break;
- case 7:
- if (colorF == 1) {
- colorF = 0;
- saturation = 255;
- value = 255;
- if (color == 0) {
- color = 96;
- }
- else if (color == 96) {
- color = 0;
- }
- else color = 0;
- }
- break;
- }
- }
- justonce = 0;
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- if (count < NUM_LEDS && count >= 0) {
- leds[count] = CHSV(color, saturation, value);
- }
- }
- }
- void rainDrop() {
- static boolean justonce;
- static byte count;
- static byte color;
- static boolean resetF;
- static byte saturation = 255;
- static byte value;
- static int droplet;
- static boolean flag2;
- static boolean modA = 1;
- static byte count2;
- static byte randombyte;
- if (once) {
- zSpeed = 2;
- once = 0;
- }
- if (resetF == 0) {
- droplet = NUM_LEDS - 2;
- resetF = 1;
- modA = 1;
- value = 25;
- randombyte = random(0, 2);
- switch (colorSF) {
- case 1:
- {
- color = random(0, 255);
- int satr = random(0, 10);
- if (satr < 2) {
- saturation = random(0, 255);
- } else saturation = 255;
- break;
- }
- case 2:
- {
- color = 160;
- saturation = 25;
- randombyte = 3;
- break;
- case 3:
- color = 160;
- saturation = 160 + random(0, 25);
- randombyte = 2;
- break;
- }
- case 4:
- {
- saturation = 255;
- if (color == 96) {
- color = 0;
- }
- else if (color == 0) {
- color = 96;
- } else color = 0;
- break;
- }
- case 5:
- {
- if (color == 160) {
- color = 0;
- saturation = 255;
- }
- else if (color == 0 && saturation == 255) {
- saturation = 0;
- }
- else if (color == 0 && saturation == 0) {
- color = 160;
- saturation = 255;
- }
- else color = 0;
- break;
- }
- case 6:
- {
- saturation = 255;
- if (color == 215) {
- color = 85;
- }
- else if (color == 85) {
- color = 139;
- }
- else if (color == 139) {
- color = 64;
- }
- else if (color == 64) {
- color = 215;
- }
- else color = 215;
- break;
- }
- case 7:
- {
- saturation = colorHSV.s;
- color = colorHSV.h;
- break;
- }
- }
- }
- if (value < 254 && (droplet + 2) >= 0) {
- value++;
- count = 0;
- }
- if (value == 254 && count < 56) {
- if (zFlag == 1 && justonce == 1) {
- justonce = 0;
- count++;
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- }
- if (count > 55) {
- if (droplet + 2 >= 0 && flag2 == 0) {
- //droplet = droplet - 1;
- modA = 0;
- flag2 = 1;
- }
- else if (flag2 == 1 && count < 225) {
- count++;
- if (count > 75 && droplet + 2 >= 0) {
- count = 200;
- count2++;
- if (count2 > randombyte) {
- count2 = 0;
- droplet = droplet - 1;
- }
- }
- }
- }
- if (droplet + 2 <= 0) {
- flag2 = 0;
- value = 50;
- count = 0;
- resetF = 0;
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- if ((droplet - 2) >= 0 && (droplet - 2) < NUM_LEDS) {
- leds[droplet - 2] = CHSV(color, saturation, 0);
- }
- if ((droplet - 1) >= 0 && (droplet - 1) < NUM_LEDS) {
- leds[droplet - 1] = CHSV(color, saturation, value >> modA);
- }
- if ((droplet) >= 0 && (droplet) < NUM_LEDS) {
- leds[droplet] = CHSV(color, saturation, value);
- }
- if ((droplet + 1) >= 0 && (droplet + 1) < NUM_LEDS) {
- leds[droplet + 1] = CHSV(color, saturation, value >> 1);
- }
- if ((droplet + 2) >= 0 && (droplet + 2) < NUM_LEDS) {
- leds[droplet + 2] = CHSV(color, saturation, 0);
- }
- }
- }
- void colorWhipe() {
- static boolean justonce;
- static byte count;
- static byte color = 87;
- static byte saturation = 255;
- static byte bgcolor = 160;
- static byte currentpixel;
- static boolean resetF;
- static byte bgsaturation = 255;
- static byte flip = 1;
- byte modA;
- if (once) {
- resetF = 0;
- flip = 1;
- }
- if (resetF == 0) {
- if (colorSF == 1) {
- bgcolor = color;
- color = rand();
- saturation = 255;
- bgsaturation = 255;
- }
- if (colorSF == 2) {
- if (flip == 1) {
- color = colorHSV.h;
- saturation = colorHSV.s;
- bgcolor = colorHSV.h - 90;
- bgsaturation = colorHSV.s;
- flip = 0;
- } else {
- color = colorHSV.h - 90;
- saturation = colorHSV.s;
- bgcolor = colorHSV.h;
- bgsaturation = colorHSV.s;
- flip = 1;
- }
- }
- if (colorSF == 3) {
- if (flip == 1) {
- color = 0;
- saturation = 255;
- bgcolor = 96;
- bgsaturation = 255;
- flip = 2;
- } else if (flip == 2) {
- color = 96;
- saturation = 255;
- bgcolor = 0;
- bgsaturation = 255;
- flip = 1;
- }
- }
- if (colorSF == 4) {
- if (flip == 1) {
- color = 0;
- saturation = 255;
- bgcolor = 160;
- bgsaturation = 255;
- flip = 2;
- } else if (flip == 2) {
- color = 160;
- saturation = 255;
- bgcolor = 0;
- bgsaturation = 0;
- flip = 3;
- } else if (flip == 3) {
- color = 0;
- saturation = 0;
- bgcolor = 160;
- bgsaturation = 255;
- flip = 1;
- }
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CHSV(bgcolor, bgsaturation, 125);
- }
- resetF = 1;
- currentpixel = NUM_LEDS - 1;
- }
- if (zFlag == 1 && justonce == 1) {
- modA = random(0, 100);
- if (modA < 55) {
- currentpixel = currentpixel - 1;
- }
- else {
- currentpixel = currentpixel + 1;
- }
- justonce = 0;
- }
- else if (zFlag == 0) {
- justonce = 1;
- }
- if (currentpixel > NUM_LEDS - 1) {
- currentpixel = NUM_LEDS - 1;
- }
- if (currentpixel < 1) {
- resetF = 0;
- }
- for (int i = 0; i < NUM_LEDS; i++) {
- if ((currentpixel - 1) < NUM_LEDS && (currentpixel - 1) >= 0) {
- leds[currentpixel - 1] = CHSV(bgcolor, bgsaturation, 125);
- }
- if (currentpixel < NUM_LEDS && currentpixel >= 0) {
- leds[currentpixel] = CHSV(color, saturation, 255);
- }
- }
- }
- void patriotic1() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement