Guest User

LEDbox

a guest
Dec 30th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 46.79 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LCD.h>
  3. #include <EEPROM.h>
  4. #include <Switch.h>
  5. #include <TimerOne.h>
  6. #include <LiquidCrystal.h>
  7. #include <MENWIZ.h>
  8. #include <buttons.h>
  9. #include <math.h>
  10. #include <Adafruit_PWMServoDriver.h>
  11. #include <Encoder.h>
  12. #include <FastLED.h>
  13.  
  14.  
  15. //LCD outputs
  16.  
  17.  
  18.  
  19. #define LED_PIN     51
  20. #define COLOR_ORDER GRB
  21. #define CHIPSET     LPD8806
  22. #define NUM_LEDS    120
  23.  
  24. Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x42);
  25.  
  26. //encoders
  27.  
  28. Encoder speedsE(18, 47);
  29. Encoder redE(19, 49);
  30. Encoder greenE(2, 51);
  31. Encoder blueE(3, A3);
  32.  
  33. unsigned int SpeedRead = 0;
  34.  
  35. //zone colors and speed
  36. byte newGreenPos = 0;
  37. byte newRedPos = 0;
  38. byte newBluePos = 0;
  39. byte newSpeedPos = 0;
  40. unsigned int z1Speed = 0;
  41. byte z1Red = 0;
  42. byte z1Blue = 0;
  43. byte z1Green = 0;
  44. unsigned int z2Speed = 0;
  45. byte z2Red = 0;
  46. byte z2Blue = 0;
  47. byte z2Green = 0;
  48. unsigned int z3Speed = 0;
  49. byte z3Red = 0;
  50. byte z3Blue = 0;
  51. byte z3Green = 0;
  52. unsigned int z4Speed = 0;
  53. byte z4Red = 0;
  54. byte z4Blue = 0;
  55. byte z4Green = 0;
  56. byte zRed = 0;
  57. byte zBlue = 0;
  58. byte zGreen = 0;
  59. unsigned int zSpeed = 0;
  60. byte zonePattern = 0;
  61. byte DisplaySpeed = 0;
  62. boolean colorF = 0;
  63. boolean SpeedF = 0;
  64.  
  65. CRGB leds[NUM_LEDS];
  66.  
  67. byte rs = 12;
  68. byte e = 11;
  69. byte d4 = 10;
  70. byte d5 = 9;
  71. byte d6 = 8;
  72. byte d7 = 7;
  73.  
  74. //LED Information
  75. struct fade {
  76.   unsigned char r, g, b, f;
  77. };
  78.  
  79. struct fade *lights;
  80.  
  81. //zone pattern arras
  82. byte zone1pattern[24];
  83. byte zone2pattern[24];
  84. byte zone3pattern[24];
  85. byte zone4pattern[24];
  86. //xxxxxxxxxxxxxxxxxx
  87. //Chasing Programs
  88. //xxxxxxxxxxxxxxxxxx
  89.  
  90. //Rainbow
  91.  
  92. byte rainbowpattern[24] = {
  93.    250, 0, 0, 32, 32, 32, 64, 64, 64, 96, 96, 96, 128, 128, 128, 160, 160, 160, 192, 192, 192, 224, 224, 250};
  94.  
  95. byte rainbowfadepattern[24] = {
  96.   0, 11, 22, 32, 42, 52, 64, 74, 84, 96, 106, 116, 128, 138, 148, 160, 170, 180, 192, 202, 212, 224, 234, 244};
  97.  
  98. byte lazer[24] = {
  99.   10, 10, 10, 10, 10, 10, 10, 255, 255, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
  100.  
  101. byte longstreakspattern[24] = {
  102.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 7, 15, 30, 50, 100, 150, 200, 255, 255, 0, 0};
  103.  
  104. byte shortstreakspattern[24] = {
  105.   1, 7, 50, 150, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  106.  
  107. byte diamondfadepattern[24] = {
  108.   0, 1, 1, 3, 7, 15, 30, 50, 100, 150, 200, 255, 200, 200, 150, 100, 50, 30, 15, 7, 3, 1, 1, 0};  
  109.  
  110. byte copspattern[24] = {
  111.   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160};
  112.  
  113. // faders
  114.  
  115. int fader[] = {
  116.   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};
  117.  
  118. int faderoff[] = {
  119.   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};
  120.  
  121. const char faderLength = 31;
  122.  
  123. //xxxxxxxxxxxxxxxxxx
  124. //Patriotic Programs
  125. //xxxxxxxxxxxxxxxxxx
  126.  
  127. //Patriotic One
  128.  
  129. int patriotic1Red[] = {
  130.   255, 255, 255, 255, 255, 255, 0, 0, 0};
  131. int patriotic1Blue[] = {
  132.   244, 244, 244, 0, 0, 0, 255, 255, 255};
  133. int patriotic1Green[] = {
  134.   255, 255, 255, 0, 0, 0, 0, 0, 0};
  135. const char patriotic1Length = 9;
  136.  
  137. void patternShift(int colorr[], int colorb[], int colorg[], int arraySize);
  138.  
  139. #define LastZone1Pixel 30 //Zone1 is ten pixels in length
  140. #define LastZone2Pixel 59 //Zone2 is ten pixels in length (10 zone 1 pixels + 10 zone 2 pixels = 20)
  141. #define LastZone3Pixel 90 //Zone2 is ten pixels in length (10 zone 1 pixels + 10 zone 2 pixels + 10 zone 3 pixels = 20)
  142. #define LastZone4Pixel 120 //Zone2 is twenty pixels in length (10 zone 1 pixels + 10 zone 2 pixels + 10 Zone 3 pixels + 20 Zone 4 pixels = 50)
  143.  
  144. //LASTzone4Pixel should always be equal to NUM_LEDS
  145.  
  146. //Relay Controllers
  147.  
  148.  
  149. const int out1 = 39;
  150. const int out2 = 38;
  151. const int out3 = 41;
  152. const int out4 = 40;
  153. const int out5 = 43;
  154. const int out6 = 42;
  155.  
  156. //Navigation
  157. #define UP_BUTTON_PIN       22
  158. #define DOWN_BUTTON_PIN       24
  159. #define ESCAPE_BUTTON_PIN       26
  160. #define CONFIRM_BUTTON_PIN       28
  161.  
  162.  
  163. //debounce
  164. Switch speedSelect = Switch(A9, INPUT, HIGH, 5);
  165. Switch colorSelect = Switch(A8, INPUT, HIGH, 5);
  166. Switch zone1 = Switch(30, INPUT_PULLUP, LOW, 5);
  167. Switch zone2 = Switch(32, INPUT_PULLUP, LOW, 5);
  168. Switch zone3 = Switch(46, INPUT_PULLUP, LOW, 5);
  169. Switch zone4 = Switch(50, INPUT_PULLUP, LOW, 5);
  170.  
  171. //zone select funtions
  172. byte Function1 = 127;
  173. byte Function2 = 127;
  174. byte Function3 = 127;
  175. byte Function4 = 127;
  176. byte zone1Function = 128;
  177. byte zone2Function = 128;
  178. byte zone3Function = 128;
  179. byte zone4Function = 128;
  180.  
  181.  
  182. typedef void (*LEDfunctions) ();
  183.  
  184. LEDfunctions functionsArray [22] =
  185. {
  186.   spacing,
  187.   off,
  188.   custom,
  189.   white,
  190.   green,
  191.   red,
  192.   blue,
  193.   yellow,
  194.   orange,
  195.   pink,
  196.   purple,
  197.   marine,
  198.   grassgreen,
  199.   rainbow,
  200.   rainbowfade,
  201.   longstreaks,
  202.   shortstreaks,
  203.   diamondfade,
  204.   customlazer,
  205.   cops,
  206.   cops1,
  207.   patriotic1,
  208. };
  209.  
  210.  
  211. LiquidCrystal lcd(rs, e, d4, d5, d6, d7);
  212.  
  213. //state machine timers
  214. byte btnInterval = 50;
  215. long int btnCheck = 0;
  216. //int ledInterval = 100;
  217. long int ledWrite = 0;
  218. byte setpInterval = 150;
  219. long int blinkDo;
  220.  
  221. unsigned long z1start = millis();
  222. unsigned long z2start = millis();
  223. unsigned long z3start = millis();
  224. unsigned long z4start = millis();
  225. unsigned long flasherstart = millis();
  226. unsigned long flasherstart1 = millis();
  227. int flasherinterval = 135;
  228.  
  229. //variables
  230.  
  231. //ledAction : An array for the "states" of four LED lights that are integrated with buttons.
  232. //Each value of the array represents a button's light.
  233. //0 is off, 1 is on, 2 is "was off, now blinking" and 3 is "was on, now blinking"
  234.  
  235. byte ledAction[] = {
  236.   0, 0, 0, 0};
  237.  
  238. byte led1Action = 0;
  239. byte led2Action = 1;
  240. byte led3Action = 2;
  241. byte led4Action = 3;
  242.  
  243. //the actual pin locations for the LED lights
  244. byte pinForLedAtSwitch[] = {
  245.   31, 33, 35, 37};
  246.  
  247.  
  248. //turn off the LED lights initially
  249. byte buttonLEDstate[] = {
  250.   LOW, LOW, LOW, LOW};
  251.  
  252. //timers for the blinking of the lights when ledAction values are 2 or 3
  253. unsigned long ledPrevMillis = 0;
  254. const int ledinterval = 600;
  255.  
  256. boolean on = 0;
  257. unsigned long SpeedPrevTime = 0;
  258. //keep track of what zone we are setting up
  259. byte zoneSetup = 0;
  260.  
  261. //Menu Variables
  262. menwiz menu;
  263. const int time = 6500;
  264.  
  265. void setup() {
  266.   Serial.begin(115200); //Start Serial for Debug
  267.   lcd.begin(20, 4); //init lcd screen
  268.   //LED STRIP SETUP
  269.  
  270.   FastLED.addLeds<LPD8806, BRG>(leds, NUM_LEDS);
  271.  
  272.   //Small LED Controller
  273.  
  274.   pwm.begin();
  275.   pwm.setPWMFreq(1600);
  276.   uint8_t twbrbackup = TWBR;
  277.   // must be changed after calling Wire.begin() (inside pwm.begin())
  278.   TWBR = 12;
  279.  
  280.   //big button red
  281.   pwm.setPWM(0, 4096, 0);
  282.   //big button green
  283.   pwm.setPWM(1, 4096, 0);
  284.   //big button blue
  285.   pwm.setPWM(2, 4096, 0);
  286.   //speed button blue
  287.   pwm.setPWM(8, 40, 0);
  288.   //speed button green
  289.   pwm.setPWM(9, 40, 0);
  290.   //speed button red
  291.   pwm.setPWM(10, 30, 0);
  292.   //red rotary encoder
  293.   pwm.setPWM(4, 25, 0);
  294.   //green rotary encoder
  295.   pwm.setPWM(5, 25, 0);
  296.   //blue rotary encoder
  297.   pwm.setPWM(6, 25, 0);
  298.   //these control RELAYs, innitially set too OFF
  299.   pinMode(out1, OUTPUT);
  300.   pinMode(out2, OUTPUT);
  301.   pinMode(out3, OUTPUT);
  302.   pinMode(out4, OUTPUT);
  303.   pinMode(out5, OUTPUT);
  304.   pinMode(out6, OUTPUT);
  305.  
  306.   digitalWrite(out1, HIGH);
  307.   digitalWrite(out2, HIGH);
  308.   digitalWrite(out3, HIGH);
  309.   digitalWrite(out4, HIGH);
  310.   digitalWrite(out5, HIGH);
  311.   digitalWrite(out6, HIGH);
  312.   //set the pinForLedAtSwitchs variables to a output
  313.   pinMode(pinForLedAtSwitch[0], OUTPUT);
  314.   pinMode(pinForLedAtSwitch[1], OUTPUT);
  315.   pinMode(pinForLedAtSwitch[2], OUTPUT);
  316.   pinMode(pinForLedAtSwitch[3], OUTPUT);
  317.  
  318.   //menus
  319.   _menu *r,*s1,*s2;
  320.   menu.begin(&lcd,20,4);    
  321.   //menu.addUsrNav(navcheck, 4);
  322.   r=menu.addMenu(MW_ROOT,NULL,F("Make Selection"));
  323.   s1=menu.addMenu(MW_VAR,r,F("Stop Selected Zone"));
  324.   s1->addVar(MW_ACTION,zoneOff);
  325.   s1=menu.addMenu(MW_SUBMENU,r,F("Solid Colors"));
  326.   s2=menu.addMenu(MW_VAR,s1,F("Custom Color")); //will call function 'White' if that menu selection is made.
  327.   s2->addVar(MW_ACTION,customZone);
  328.   s2=menu.addMenu(MW_VAR,s1,F("White")); //will call function 'White' if that menu selection is made.
  329.   s2->addVar(MW_ACTION,whiteZone);
  330.   s2=menu.addMenu(MW_VAR,s1,F("Red")); //will call function 'White' if that menu selection is made.
  331.   s2->addVar(MW_ACTION,redZone);
  332.   s2=menu.addMenu(MW_VAR,s1,F("Green")); //will1 call function 'White' if that menu selection is made.
  333.   s2->addVar(MW_ACTION,greenZone);
  334.   s2=menu.addMenu(MW_VAR,s1,F("Blue")); //will call function 'White' if that menu selection is made.
  335.   s2->addVar(MW_ACTION,blueZone);
  336.   s2=menu.addMenu(MW_VAR,s1,F("Yellow")); //will call function 'White' if that menu selection is made.
  337.   s2->addVar(MW_ACTION,yellowZone);
  338.   s2=menu.addMenu(MW_VAR,s1,F("Orange")); //will call function 'White' if that menu selection is made.
  339.   s2->addVar(MW_ACTION,orangeZone);
  340.   s2=menu.addMenu(MW_VAR,s1,F("Pink")); //will call function 'White' if that menu selection is made.
  341.   s2->addVar(MW_ACTION,pinkZone);
  342.   s2=menu.addMenu(MW_VAR,s1,F("Purple")); //will call function 'White' if that menu selection is made.
  343.   s2->addVar(MW_ACTION,purpleZone);
  344.   s2=menu.addMenu(MW_VAR,s1,F("Marine")); //will call function 'White' if that menu selection is made.
  345.   s2->addVar(MW_ACTION,marineZone);
  346.   s2=menu.addMenu(MW_VAR,s1,F("Grass Green")); //will call function 'White' if that menu selection is made.
  347.   s2->addVar(MW_ACTION,grassgreenZone);
  348.   s1=menu.addMenu(MW_SUBMENU,r,F("Custom Chasing"));
  349.   s2=menu.addMenu(MW_VAR,s1,F("Rainbow"));
  350.   s2->addVar(MW_ACTION,rainbowZone);
  351.   s2=menu.addMenu(MW_VAR,s1,F("Rainbow Fade"));
  352.   s2->addVar(MW_ACTION,rainbowfadeZone);
  353.   s2=menu.addMenu(MW_VAR,s1,F("Long Streaks"));
  354.   s2->addVar(MW_ACTION,longstreakZone);
  355.   s2=menu.addMenu(MW_VAR,s1,F("Short Streaks"));
  356.   s2->addVar(MW_ACTION,shortstreakZone);
  357.   s2=menu.addMenu(MW_VAR,s1,F("Diamond Fade"));
  358.   s2->addVar(MW_ACTION,diamondfadeZone);
  359.   s2=menu.addMenu(MW_VAR,s1,F("Custom Lazer"));
  360.   s2->addVar(MW_ACTION,customlazerZone);
  361.   s2=menu.addMenu(MW_VAR,s1,F("Cops 1"));
  362.   s2->addVar(MW_ACTION,copsZone);
  363.   s2=menu.addMenu(MW_VAR,s1,F("Cops 2"));
  364.   s2->addVar(MW_ACTION,cops2Zone);
  365.   s1=menu.addMenu(MW_SUBMENU,r,F("Fading Colors"));
  366.   s1=menu.addMenu(MW_SUBMENU,r,F("Christmas Colors"));
  367.   s1=menu.addMenu(MW_SUBMENU,r,F("Holloween Colors"));
  368.   s1=menu.addMenu(MW_SUBMENU,r,F("Easter Colors"));
  369.   s1=menu.addMenu(MW_SUBMENU,r,F("Patriotic Colors"));
  370.   s2=menu.addMenu(MW_VAR,s1,F("Red White Blue Chase"));
  371.   s2->addVar(MW_ACTION,patriotic1Zone);
  372.   menu.navButtons(UP_BUTTON_PIN,DOWN_BUTTON_PIN,ESCAPE_BUTTON_PIN,CONFIRM_BUTTON_PIN);
  373.   //if a certain amount of time has passed, load the "user screen", function "screen"
  374.   menu.addUsrScreen(screen, time);
  375.  
  376. }
  377.  
  378.  
  379. //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  380. //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  381. //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  382. //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  383. //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  384. //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  385. //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  386. //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  387. //ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
  388.  
  389. void loop(){
  390.   menu.draw();
  391.   checkButtons();
  392.   blinker();
  393.  
  394.   if(ledAction[led1Action] == 1 || ledAction[led2Action] == 1 || ledAction[led3Action] == 1 || ledAction[led4Action] == 1){
  395.     zoneIncrementers();
  396.   }
  397.  
  398.   LEDshow();
  399.   FastLED.show();
  400. }
  401.  
  402. void LEDshow() {
  403.   if (ledAction[led1Action] == 1) {
  404.     functionsArray [zone1Function] ();
  405.   }
  406.   if (ledAction[led2Action] == 1) {
  407.     functionsArray [zone2Function] ();
  408.   }
  409.   if (ledAction[led3Action] == 1) {
  410.     functionsArray [zone3Function] ();
  411.   }
  412.   if (ledAction[led4Action] == 1) {
  413.     functionsArray [zone4Function] ();
  414.   }    
  415. }
  416.  
  417. void zoneOn(){
  418.   switch(zoneSetup) {
  419.   case 1:
  420.     ledAction[led1Action] = 1;  //turn on it's buttons LED light and
  421.     zoneSetup = 0;  //let us no we are no longer setting up a zone
  422.     digitalWrite(out1, LOW);//turn on the zones relay
  423.     break;
  424.   case 2:
  425.     ledAction[led2Action] = 1;
  426.     zoneSetup = 0;
  427.     digitalWrite(out2, LOW);
  428.     break;
  429.   case 3:
  430.     ledAction[led3Action] = 1;
  431.     zoneSetup = 0;
  432.     digitalWrite(out3, LOW);
  433.     break;
  434.   case 4:
  435.     ledAction[led4Action] = 1;
  436.     zoneSetup = 0;
  437.     digitalWrite(out4, LOW);
  438.     break;
  439.   }  
  440. }
  441.  
  442. void patternShift(byte zone[]) {
  443.   int tempZone;
  444.   for (int i=24; i>1; i--)
  445.   {
  446.     tempZone = zone[23];
  447.     zone[23] = zone[i];
  448.     zone[i] = tempZone;
  449.   }
  450. }
  451.  
  452. void zoneIncrementers() {
  453.   unsigned long z1 = millis();
  454.   unsigned long z2 = millis();
  455.   unsigned long z3 = millis();
  456.   unsigned long z4 = millis();
  457.  
  458.   if(z1 - z1start >= z1Speed << 1){
  459.     patternShift(zone1pattern);
  460.     z1start = z1;
  461.   }
  462.   if(z2 - z2start >= z2Speed << 1){
  463.     patternShift(zone2pattern);
  464.     z2start = z2;
  465.   }
  466.   if(z3 - z3start >= z3Speed << 1){
  467.     patternShift(zone3pattern);
  468.     z3start = z3;
  469.   }
  470.   if(z4 - z4start >= z4Speed << 1){
  471.     patternShift(zone4pattern);
  472.     z4start = z4;
  473.   }
  474. }
  475.  
  476. bool FunctionForEachPixel (byte icNumber, byte index, int Function)
  477. {
  478.   if (icNumber <= LastZone1Pixel &&  Function1 == Function){
  479.     zRed = z1Red;
  480.     zBlue = z1Blue;
  481.     zGreen = z1Green;
  482.     zSpeed = z1Speed;
  483.     zonePattern = zone1pattern[index];
  484.     return true ;
  485.   } //function 2 is the selected function for zone 1
  486.   if (icNumber > LastZone1Pixel && icNumber <= LastZone2Pixel && Function2 == Function) {
  487.     zRed = z2Red;
  488.     zBlue = z2Blue;
  489.     zGreen = z2Green;
  490.     zSpeed = z2Speed;
  491.     zonePattern = zone2pattern[index];
  492.     return true ;
  493.   }
  494.   if (icNumber > LastZone2Pixel && icNumber <= LastZone3Pixel && Function3 == Function) {
  495.     zRed = z3Red;
  496.     zBlue = z3Blue;
  497.     zGreen = z3Green;
  498.      zSpeed = z3Speed;
  499.     zonePattern = zone3pattern[index];
  500.     return true ;
  501.   }
  502.   if (icNumber > LastZone3Pixel && icNumber <= LastZone4Pixel && Function4 == Function) {
  503.     zRed = z4Red;
  504.     zBlue = z4Blue;
  505.     zGreen = z4Green;
  506.      zSpeed = z4Speed;
  507.     zonePattern = zone4pattern[index];
  508.     return true ;
  509.   }
  510.   return false ;
  511. }
  512. // zone color fuction setting functions O.o
  513.  
  514. void zoneOff() {
  515.   long int time = millis();
  516.   long int timer2 = time + 3500;
  517.   switch(zoneSetup){
  518.   case 0:
  519.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  520.     break;
  521.   case 1:
  522.     ledAction[led1Action] = 0; //turn off that zone's button light and
  523.     zoneSetup = 0;
  524.     digitalWrite(out1, HIGH); //turn off the relay corresponding to the zone.
  525.     zone1Function = 1;
  526.     Function1 = 1;
  527.     break;
  528.   case 2:
  529.     ledAction[led2Action] = 0;
  530.     zoneSetup = 0;
  531.     digitalWrite(out2, HIGH);
  532.     zone2Function = 1;
  533.     Function2 = 1;
  534.     break;
  535.   case 3:
  536.     ledAction[led3Action] = 0;
  537.     zoneSetup = 0;
  538.     digitalWrite(out3, HIGH);
  539.     zone3Function = 1;
  540.     Function3 = 1;
  541.     break;
  542.   case 4:
  543.     ledAction[led4Action] = 0;
  544.     zoneSetup = 0;
  545.     digitalWrite(out4, HIGH);
  546.     zone4Function = 1;
  547.     Function4 = 1;
  548.     break;  
  549.   }
  550.   off();
  551. }
  552.  
  553. void setups(){
  554.   redE.write(0);
  555.   blueE.write(0);
  556.   greenE.write(0);
  557.   speedsE.write(0);
  558.   int stime = 0;
  559.   unsigned long ttime = 0;
  560.  
  561.   while (colorF == 0 || SpeedF == 0 || stime < 2500){
  562.     setupScreen();
  563.     colorSelect.poll();
  564.     speedSelect.poll();
  565.     encoderLimits();
  566.     speedHandler();
  567.     pwmControl();
  568.     blinker();
  569.  
  570.     if(colorSelect.pushed()){
  571.       if(newRedPos == 5){
  572.         newRedPos = 0;
  573.       }
  574.       if(newGreenPos == 5){
  575.         newGreenPos = 0;
  576.       }
  577.       if(newBluePos == 5){
  578.         newBluePos = 0;
  579.       }
  580.  
  581.       if(zoneSetup == 1) {
  582.         z1Red = newRedPos << 1;
  583.         z1Blue = newBluePos << 1;
  584.         z1Green = newGreenPos << 1;    
  585.       }
  586.       if(zoneSetup == 2) {
  587.         z2Red = newRedPos << 1;
  588.         z2Blue = newBluePos << 1;
  589.         z2Green = newGreenPos << 1;
  590.       }
  591.       if(zoneSetup == 3) {
  592.         z3Red = newRedPos << 1;
  593.         z3Blue = newBluePos << 1;
  594.         z3Green = newGreenPos << 1;
  595.        }
  596.       if(zoneSetup == 4) {
  597.         z4Red = newRedPos << 1;
  598.         z4Blue = newBluePos << 1;
  599.         z4Green = newGreenPos << 1;
  600.       }
  601.       colorF = 1;
  602.     }  
  603.  
  604.     if(speedSelect.pushed()){
  605.       if(zoneSetup == 1) {
  606.         z1Speed = SpeedRead;
  607.       }
  608.       if(zoneSetup == 2){
  609.         z2Speed = SpeedRead;
  610.       }  
  611.       if(zoneSetup == 3){
  612.         z3Speed = SpeedRead;
  613.       }
  614.       if(zoneSetup == 4){
  615.         z4Speed = SpeedRead;
  616.       }  
  617.       SpeedF = 1;
  618.     }  
  619.  
  620.     pwmControl();
  621.  
  622.     if(SpeedF == 0 || colorF == 0){
  623.       ttime = millis();
  624.     }
  625.     if(SpeedF == colorF == 1){
  626.       stime = millis() - ttime;
  627.  
  628.     }
  629.   }
  630. }
  631.  
  632. void speedHandler() {
  633.   if(newSpeedPos  >= 10 && newSpeedPos < 17){
  634.     SpeedRead = 15;
  635.     DisplaySpeed = 10;
  636.   }
  637.   else if(newSpeedPos < 24){
  638.     SpeedRead = 65;
  639.     DisplaySpeed = 9;
  640.   }
  641.   else if(newSpeedPos < 31){
  642.     SpeedRead = 120;
  643.     DisplaySpeed = 8;
  644.   }
  645.   else if(newSpeedPos < 38){
  646.     SpeedRead = 180;
  647.     DisplaySpeed = 7;
  648.   }
  649.   else if(newSpeedPos < 45){
  650.     SpeedRead = 240;
  651.     DisplaySpeed = 6;
  652.   }
  653.   else if(newSpeedPos < 52){
  654.     SpeedRead = 300;
  655.     DisplaySpeed = 5;
  656.   }
  657.   else if(newSpeedPos < 59){
  658.     SpeedRead = 360;
  659.     DisplaySpeed = 4;
  660.   }
  661.   else if(newSpeedPos < 66){
  662.     SpeedRead = 420;
  663.     DisplaySpeed = 3;
  664.   }
  665.   else if(newSpeedPos <= 73){
  666.     SpeedRead = 480;
  667.     DisplaySpeed = 2;
  668.   }
  669.   else if(newSpeedPos <= 80){
  670.     SpeedRead = 500;
  671.     DisplaySpeed = 1;
  672.   }
  673. }
  674.  
  675. void encoderLimits() {
  676.   newRedPos = redE.read();
  677.   newBluePos = blueE.read();
  678.   newGreenPos = greenE.read();
  679.   newSpeedPos = speedsE.read();
  680.  
  681.  
  682.   if(newSpeedPos > 80) {
  683.     newSpeedPos = 80;
  684.     speedsE.write(80);
  685.   }
  686.   if(newSpeedPos < 10) {
  687.     newSpeedPos = 10;
  688.     speedsE.write(10);
  689.   }
  690.  
  691.   if(newRedPos < 5) {
  692.     newRedPos = 5;
  693.     redE.write(5);
  694.   }
  695.   if(newRedPos > 127) {
  696.     newRedPos = 127;
  697.     redE.write(127);
  698.   }
  699.  
  700.   if(newBluePos > 127) {
  701.     newBluePos = 127;
  702.     blueE.write(127);
  703.   }
  704.  
  705.   if(newBluePos < 5) {
  706.     newBluePos = 5;
  707.     blueE.write(5);
  708.   }
  709.  
  710.   if(newGreenPos > 127) {
  711.     newGreenPos = 127;
  712.     greenE.write(127);
  713.   }
  714.  
  715.   if(newGreenPos < 5) {
  716.     newGreenPos = 5;
  717.     greenE.write(5);
  718.   }
  719.  
  720. }
  721.  
  722. void setupScreen(){
  723.   lcd.setCursor(0,0);
  724.   lcd.print("Zone ");
  725.   lcd.print(zoneSetup);
  726.   lcd.print(" Program Setup");
  727.   lcd.setCursor(0,1);
  728.   lcd.print("Color Selected: ");
  729.   if(colorF == 1) {
  730.     lcd.print("Yes");
  731.   }
  732.   else {
  733.     lcd.print("No");
  734.   }
  735.   lcd.setCursor(0,2);
  736.   lcd.print("Speed Selected: ");
  737.   if(SpeedF == 1) {
  738.     lcd.print("Yes");
  739.   }
  740.   else {
  741.     lcd.print("No");
  742.   }
  743.   lcd.setCursor(0,3);
  744.   lcd.print("SP:");
  745.   if((DisplaySpeed)<10){
  746.     lcd.print(DisplaySpeed);
  747.     lcd.print(" ");
  748.   }
  749.   else {
  750.     lcd.print(DisplaySpeed);
  751.   }
  752.   lcd.setCursor(5,3);
  753.   lcd.print(" R:");
  754.   if(newRedPos == 5){
  755.     lcd.print("0");
  756.   }
  757.   else {
  758.     if((newRedPos >> 2)<10){
  759.       lcd.print(newRedPos >> 2);
  760.       lcd.print(" ");
  761.     }
  762.     else {
  763.       lcd.print(newRedPos >> 2);
  764.     }
  765.   }
  766.   lcd.setCursor(10,3);
  767.   lcd.print(" G:");
  768.   if(newGreenPos == 5){
  769.     lcd.print("0");
  770.   }
  771.   else {
  772.     if((newGreenPos >> 2)<10){
  773.       lcd.print(newGreenPos >> 2);
  774.       lcd.print(" ");
  775.     }
  776.     else {
  777.       lcd.print(newGreenPos >> 2);
  778.     }
  779.   }
  780.   lcd.setCursor(15,3);
  781.   lcd.print(" B:");
  782.   if(newBluePos == 5){
  783.     lcd.print("0");
  784.   }
  785.   else {
  786.     if((newBluePos >> 2)<10){
  787.       lcd.print(newBluePos >> 2);
  788.       lcd.print(" ");
  789.     }
  790.     else {
  791.       lcd.print(newBluePos >> 2);
  792.     }
  793.   }
  794. }
  795.  
  796. void pwmControl(){
  797.   unsigned long SpeedTime = millis();
  798.  
  799.   if (SpeedTime - SpeedPrevTime > SpeedRead) {
  800.     SpeedPrevTime = SpeedTime;
  801.     on = !on;  
  802.   }
  803.  
  804.   if(SpeedF == 0){
  805.  
  806.     pwm.setPWM(8, on*4096, 0);
  807.     //speed button green
  808.     pwm.setPWM(9, on*4096, 0);
  809.     //speed button red
  810.     pwm.setPWM(10, on*4096, 0);
  811.   }
  812.  
  813.   if(colorF == 0){
  814.  
  815.     if (newRedPos == 5){
  816.       pwm.setPWM(0, 4096, 0); //big button Red
  817.       pwm.setPWM(4, 4096, 0); //red rotary encoder
  818.     }
  819.     else {
  820.       pwm.setPWM(0, newRedPos << 3, 0); //big button Red
  821.       pwm.setPWM(4, newRedPos << 3, 0); //Red encoder
  822.     }
  823.     if (newGreenPos == 5){
  824.       pwm.setPWM(1, 4096, 0); //big button Green
  825.       pwm.setPWM(5, 4096, 0); //green rotary
  826.     }
  827.     else  
  828.     {
  829.       pwm.setPWM(1, newGreenPos << 3, 0); //big button Green1
  830.       pwm.setPWM(5, newGreenPos << 3, 0); //green rotary encoder
  831.     }
  832.     if (newBluePos == 5){    
  833.       pwm.setPWM(2, 4096, 0); //big button blue
  834.       pwm.setPWM(6, 4096, 0); //blue rotary encoder
  835.     }
  836.     else {
  837.       pwm.setPWM(2, newBluePos << 3, 0); //big button blue
  838.       pwm.setPWM(6, newBluePos << 3, 0); //blue rotary encoder
  839.     }
  840.   }
  841.  
  842.   if(SpeedF == 1){
  843.     pwm.setPWM(8, 40, 0);
  844.     //speed button green
  845.     pwm.setPWM(9, 40, 0);
  846.     //speed button red
  847.     pwm.setPWM(10, 30, 0);
  848.   }
  849.   if(colorF == 1){
  850.     pwm.setPWM(0, 4096, 0);
  851.     //big button green
  852.     pwm.setPWM(1, 4096, 0);
  853.     //big button blue
  854.     pwm.setPWM(2, 4096, 0);
  855.     //red rotary encoder
  856.     pwm.setPWM(4, 25, 0);
  857.     //green rotary encoder
  858.     pwm.setPWM(5, 25, 0);
  859.     //blue rotary encoder
  860.     pwm.setPWM(6, 25, 0);
  861.   }
  862. }
  863.  
  864. void spacing() {  //does nothing, so that the first array value for the color programs doesn't equal zero
  865. }
  866.  
  867. void screen() {  
  868.   //these lines turn off or on any button LED, depending on its previous state. If the led was off before (blinking as a value of 2), it will
  869.   //be off now, if the led was on (blinking as a value of 3), the LED will be on now.
  870.   for (byte n = 0; n < 4; n++) {
  871.     switch(ledAction[n])
  872.     {
  873.     case 2: // blinking but was off before it was blinking
  874.       ledAction[n] = 0; //lets turn it off again
  875.       break;
  876.     case 3: // blinking but was on before it was blinking
  877.       ledAction[n] = 1; //lets turn it on again
  878.       break;
  879.     }
  880.   }
  881.   zoneSetup = 0;
  882.   //setting soneSetup to zero, lets us no that no zone is active, therefore no changes can be made.
  883.   lcd.setCursor(0,0);
  884.   lcd.print("Welcome  to  LEDbox!");
  885.   lcd.setCursor(0,1);
  886.   lcd.print("   Awaiting Input   ");
  887.   lcd.setCursor(0,2);
  888.   lcd.print(" Use Buttons Below  ");
  889.   lcd.setCursor(0,3);
  890.   lcd.print("1     2      3     4");
  891. }
  892.  
  893. void checkButtons(){
  894.   //debounce code to check for button presses
  895.   zone1.poll();
  896.   zone2.poll();
  897.   zone3.poll();
  898.   zone4.poll();
  899.   // if zone 1's button was pressed
  900.   if(zone1.pushed()) {
  901.     colorF = 0;
  902.     SpeedF = 0;
  903.     for (byte n = 0; n < 4; n++) {
  904.       switch(ledAction[n])
  905.       {
  906.       case 2: // blinking but was off before it was blinking
  907.         ledAction[n] = 0; //lets turn it off again
  908.         break;    
  909.       case 3: // blinking but was on before it was blinking
  910.         ledAction[n] = 1; //lets turn it on again
  911.         break;
  912.       }
  913.     }
  914.     //if button one is off, now it is blinking. 2 signifies that it was previously off.
  915.     if(ledAction[led1Action] == 0){
  916.       ledAction[led1Action] = 2;
  917.     }
  918.     //if button one is on, now it is blinking. 3 signifies that it was previously on.
  919.     if(ledAction[led1Action] == 1){
  920.       ledAction[led1Action] = 3;
  921.     }
  922.     //simulate button press to bring up menu
  923.     menu.actNavButtons(MW_BTL);
  924.     //let the world know that we are in setting up zone 1
  925.     zoneSetup = 1;
  926.   }
  927.   if(zone2.pushed()) {
  928.     colorF = 0;
  929.     SpeedF = 0;
  930.     for (byte n = 0; n < 4; n++) {
  931.       switch(ledAction[n])
  932.       {
  933.       case 2: // blinking but was off before it was blinking
  934.         ledAction[n] = 0; //lets turn it off again
  935.         break;
  936.       case 3: // blinking but was on before it was blinking
  937.         ledAction[n] = 1; //lets turn it on again
  938.         break;
  939.       }
  940.  
  941.     }
  942.     if(ledAction[led2Action] == 0){
  943.       ledAction[led2Action] = 2;
  944.     }
  945.     if(ledAction[led2Action] == 1){
  946.       ledAction[led2Action] = 3;
  947.     }
  948.     menu.actNavButtons(MW_BTL);
  949.     zoneSetup = 2;
  950.   }
  951.   if(zone3.pushed()) {
  952.     colorF = 0;
  953.     SpeedF = 0;
  954.     for (byte n = 0; n < 4; n++) {
  955.       switch(ledAction[n])
  956.       {
  957.       case 2: // blinking but was off before it was blinking
  958.         ledAction[n] = 0; //lets turn it off again
  959.         break;
  960.       case 3: // blinking but was on before it was blinking
  961.         ledAction[n] = 1; //lets turn it on again
  962.         break;
  963.       }
  964.  
  965.     }
  966.     if(ledAction[led3Action] == 0){
  967.       ledAction[led3Action] = 2;
  968.     }
  969.     if(ledAction[led3Action] == 1){
  970.       ledAction[led3Action] = 3;
  971.     }
  972.     menu.actNavButtons(MW_BTL);
  973.     zoneSetup = 3;
  974.   }
  975.   if(zone4.pushed()) {
  976.     colorF = 0;
  977.     SpeedF = 0;
  978.     for (byte n = 0; n < 4; n++) {
  979.       switch(ledAction[n])
  980.       {
  981.       case 2: // blinking but was off before it was blinking
  982.         ledAction[n] = 0; //lets turn it off again
  983.         break;
  984.       case 3: // blinking but was on before it was blinking
  985.         ledAction[n] = 1; //lets turn it on again
  986.         break;
  987.       }
  988.     }
  989.     if(ledAction[led4Action] == 0){
  990.       ledAction[led4Action] = 2;
  991.     }
  992.     if(ledAction[led4Action] == 1){
  993.       ledAction[led4Action] = 3;
  994.     }
  995.     menu.actNavButtons(MW_BTL);
  996.     zoneSetup = 4;
  997.   }
  998. }
  999.  
  1000. void blinker(){
  1001.   unsigned long ledCurrentMillis = millis();
  1002.   for (byte n = 0; n < 4; n++) {
  1003.     digitalWrite(pinForLedAtSwitch[n], buttonLEDstate[n]);
  1004.     switch(ledAction[n])
  1005.     {
  1006.     case 0: // steady off
  1007.       buttonLEDstate[n] = LOW;
  1008.       break;
  1009.     case 1: // steady on
  1010.       buttonLEDstate[n] = HIGH;
  1011.       break;
  1012.     case 2: // blinking but was off before it was blinking
  1013.       if (ledCurrentMillis - ledPrevMillis > ledinterval){
  1014.         ledPrevMillis = ledCurrentMillis;
  1015.         buttonLEDstate[n] = ! buttonLEDstate[n];
  1016.       }
  1017.     case 3: // blinking but was on before it was blinking
  1018.       if (ledCurrentMillis - ledPrevMillis > ledinterval){
  1019.         ledPrevMillis = ledCurrentMillis;
  1020.         buttonLEDstate[n] = ! buttonLEDstate[n];
  1021.       }
  1022.       break;
  1023.     }
  1024.   }
  1025. }
  1026.  
  1027. void customZone() {
  1028.   long int time = millis();
  1029.   long int timer2 = time + 3500;
  1030.   switch(zoneSetup){
  1031.   case 0:
  1032.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1033.     break;
  1034.   case 1:
  1035.     SpeedF = 1;
  1036.     setups();
  1037.     zone1Function = 2;
  1038.     Function1 = 2;
  1039.     break;
  1040.   case 2:
  1041.     SpeedF = 1;
  1042.     setups();
  1043.     zone2Function = 2;
  1044.     Function2 = 2;
  1045.     break;
  1046.   case 3:
  1047.     SpeedF = 1;
  1048.     setups();
  1049.     zone3Function = 2;
  1050.     Function3 = 2;
  1051.     break;
  1052.   case 4:
  1053.     SpeedF = 1;
  1054.     setups();
  1055.     zone4Function = 2;
  1056.     Function4 = 2;  
  1057.     break;  
  1058.   }
  1059.   zoneOn();
  1060. }
  1061.  
  1062. void whiteZone() {
  1063.   long int time = millis();
  1064.   long int timer2 = time + 3500;
  1065.   switch(zoneSetup){
  1066.   case 0:
  1067.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1068.     break;
  1069.   case 1:
  1070.     zone1Function = 3;
  1071.     Function1 = 3;
  1072.     break;
  1073.   case 2:
  1074.     zone2Function = 3;
  1075.     Function2 = 3;
  1076.     break;
  1077.   case 3:
  1078.     zone3Function = 3;
  1079.     Function3 = 3;
  1080.     break;
  1081.   case 4:
  1082.     zone4Function = 3;
  1083.     Function4 = 3;
  1084.     break;  
  1085.   }
  1086.   zoneOn();
  1087. }
  1088.  
  1089. void greenZone() {
  1090.   long int time = millis();
  1091.   long int timer2 = time + 3500;
  1092.   switch(zoneSetup){
  1093.   case 0:
  1094.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1095.     break;
  1096.   case 1:
  1097.     zone1Function = 4;
  1098.     Function1 = 4;
  1099.     break;
  1100.   case 2:
  1101.     zone2Function = 4;
  1102.     Function2 = 4;
  1103.     break;
  1104.   case 3:
  1105.     zone3Function = 4;
  1106.     Function3 = 4;
  1107.     break;
  1108.   case 4:
  1109.     zone4Function = 4;
  1110.     Function4 = 4;
  1111.     break;  
  1112.   }
  1113.   zoneOn();
  1114. }
  1115.  
  1116. void redZone() {
  1117.   long int time = millis();
  1118.   long int timer2 = time + 3500;
  1119.   switch(zoneSetup){
  1120.   case 0:
  1121.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1122.     break;
  1123.   case 1:
  1124.     zone1Function = 5;
  1125.     Function1 = 5;
  1126.     break;
  1127.   case 2:
  1128.     zone2Function = 5;
  1129.     Function2 = 5;
  1130.     break;
  1131.   case 3:
  1132.     zone3Function = 5;
  1133.     Function3 = 5;
  1134.     break;
  1135.   case 4:
  1136.     zone4Function = 5;
  1137.     Function4 = 5;
  1138.     break;  
  1139.   }
  1140.   zoneOn();
  1141. }
  1142.  
  1143. void blueZone() {
  1144.   long int time = millis();
  1145.   long int timer2 = time + 3500;
  1146.   switch(zoneSetup){
  1147.   case 0:
  1148.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1149.     break;
  1150.   case 1:
  1151.     zone1Function = 6;
  1152.     Function1 = 6;
  1153.     break;
  1154.   case 2:
  1155.     zone2Function = 6;
  1156.     Function2 = 6;
  1157.     break;
  1158.   case 3:
  1159.     zone3Function = 6;
  1160.     Function3 = 6;
  1161.     break;
  1162.   case 4:
  1163.     zone4Function = 6;
  1164.     Function4 = 6;
  1165.     break;  
  1166.   }
  1167.   zoneOn();
  1168. }
  1169.  
  1170. void yellowZone() {
  1171.   long int time = millis();
  1172.   long int timer2 = time + 3500;
  1173.   switch(zoneSetup){
  1174.   case 0:
  1175.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1176.     break;
  1177.   case 1:
  1178.     zone1Function = 7;
  1179.     Function1 = 7;
  1180.     break;
  1181.   case 2:
  1182.     zone2Function = 7;
  1183.     Function2 = 7;
  1184.     break;
  1185.   case 3:
  1186.     zone3Function = 7;
  1187.     Function3 = 7;
  1188.     break;
  1189.   case 4:
  1190.     zone4Function = 7;
  1191.     Function4 = 7;
  1192.     break;  
  1193.   }
  1194.   zoneOn();
  1195. }
  1196.  
  1197. void orangeZone() {
  1198.   long int time = millis();
  1199.   long int timer2 = time + 3500;
  1200.   switch(zoneSetup){
  1201.   case 0:
  1202.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1203.     break;
  1204.   case 1:
  1205.     zone1Function = 8;
  1206.     Function1 = 8;
  1207.     break;
  1208.   case 2:
  1209.     zone2Function = 8;
  1210.     Function2 = 8;
  1211.     break;
  1212.   case 3:
  1213.     zone3Function = 8;
  1214.     Function3 = 8;
  1215.     break;
  1216.   case 4:
  1217.     zone4Function = 8;
  1218.     Function4 = 8;
  1219.     break;  
  1220.   }
  1221.   zoneOn();
  1222. }
  1223.  
  1224. void pinkZone() {
  1225.   long int time = millis();
  1226.   long int timer2 = time + 3500;
  1227.   switch(zoneSetup){
  1228.   case 0:
  1229.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1230.     break;
  1231.   case 1:
  1232.     zone1Function = 9;
  1233.     Function1 = 9;
  1234.     break;
  1235.   case 2:
  1236.     zone2Function = 9;
  1237.     Function2 = 9;
  1238.     break;
  1239.   case 3:
  1240.     zone3Function = 9;
  1241.     Function3 = 9;
  1242.     break;
  1243.   case 4:
  1244.     zone4Function = 9;
  1245.     Function4 = 9;
  1246.     break;  
  1247.   }
  1248.   zoneOn();
  1249. }
  1250.  
  1251. void purpleZone() {
  1252.   long int time = millis();
  1253.   long int timer2 = time + 3500;
  1254.   switch(zoneSetup){
  1255.   case 0:
  1256.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1257.     break;
  1258.   case 1:
  1259.     zone1Function = 10;
  1260.     Function1 = 10;
  1261.     break;
  1262.   case 2:
  1263.     zone2Function = 10;
  1264.     Function2 = 10;
  1265.     break;
  1266.   case 3:
  1267.     zone3Function = 10;
  1268.     Function3 = 10;
  1269.     break;
  1270.   case 4:
  1271.     zone4Function = 10;
  1272.     Function4 = 10;
  1273.     break;  
  1274.   }
  1275.   zoneOn();
  1276. }
  1277.  
  1278. void marineZone() {
  1279.   long int time = millis();
  1280.   long int timer2 = time + 3500;
  1281.   switch(zoneSetup){
  1282.   case 0:
  1283.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1284.     break;
  1285.   case 1:
  1286.     zone1Function = 11;
  1287.     Function1 = 11;
  1288.     break;
  1289.   case 2:
  1290.     zone2Function = 11;
  1291.     Function2 = 11;
  1292.     break;
  1293.   case 3:
  1294.     zone3Function = 11;
  1295.     Function3 = 11;
  1296.     break;
  1297.   case 4:
  1298.     zone4Function = 11;
  1299.     Function4 = 11;
  1300.     break;  
  1301.   }
  1302.   zoneOn();
  1303. }
  1304.  
  1305. void grassgreenZone() {
  1306.   long int time = millis();
  1307.   long int timer2 = time + 3500;
  1308.   switch(zoneSetup){
  1309.   case 0:
  1310.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1311.     break;
  1312.   case 1:
  1313.     zone1Function = 12;
  1314.     Function1 = 12;
  1315.     break;
  1316.   case 2:
  1317.     zone2Function = 12;
  1318.     Function2 = 12;
  1319.     break;
  1320.   case 3:
  1321.     zone3Function = 12;
  1322.     Function3 = 12;
  1323.     break;
  1324.   case 4:
  1325.     zone4Function = 12;
  1326.     Function4 = 12;
  1327.     break;  
  1328.   }
  1329.   zoneOn();
  1330. }
  1331.  
  1332. void rainbowZone() {
  1333.   long int time = millis();
  1334.   long int timer2 = time + 3500;
  1335.    colorF = 1;
  1336.   switch(zoneSetup){
  1337.   case 0:
  1338.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1339.     break;
  1340.   case 1:
  1341.     setups();
  1342.     zone1Function = 13;
  1343.     Function1 = 13;
  1344.     memcpy(zone1pattern, rainbowpattern, 24);
  1345.     break;
  1346.   case 2:
  1347.   setups();
  1348.     zone2Function = 13;
  1349.     Function2 = 13;
  1350.      memcpy(zone2pattern, rainbowpattern, 24);
  1351.     break;
  1352.   case 3:
  1353.   setups();
  1354.     zone3Function = 13;
  1355.     Function3 = 13;
  1356.     memcpy(zone3pattern, rainbowpattern, 24);
  1357.     break;
  1358.   case 4:
  1359.     setups();
  1360.     zone4Function = 13;
  1361.     Function4 = 13;
  1362.     memcpy(zone4pattern, rainbowpattern, 24);
  1363.     break;  
  1364.   }
  1365.   zoneOn();
  1366. }
  1367.  
  1368. void rainbowfadeZone() {
  1369.   long int time = millis();
  1370.   long int timer2 = time + 3500;
  1371.   colorF = 1;
  1372.   switch(zoneSetup){
  1373.   case 0:
  1374.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1375.     break;
  1376.   case 1:
  1377.   setups();
  1378.   memcpy(zone1pattern, rainbowfadepattern, 24);
  1379.     zone1Function = 14;
  1380.     Function1 = 14;
  1381.     break;
  1382.   case 2:
  1383.   setups();
  1384.   memcpy(zone2pattern, rainbowfadepattern, 24);
  1385.     zone2Function = 14;
  1386.     Function2 = 14;
  1387.     break;
  1388.   case 3:
  1389.   setups();
  1390.   memcpy(zone3pattern, rainbowfadepattern, 24);
  1391.     zone3Function = 14;
  1392.     Function3 = 14;
  1393.     break;
  1394.   case 4:
  1395.   setups();
  1396.   memcpy(zone4pattern, rainbowfadepattern, 24);
  1397.     zone4Function = 14;
  1398.     Function4 = 14;
  1399.     break;  
  1400.   }
  1401.   zoneOn();
  1402. }
  1403.  
  1404. void longstreakZone() {
  1405.   long int time = millis();
  1406.   long int timer2 = time + 3500;
  1407.   switch(zoneSetup){
  1408.   case 0:
  1409.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1410.     break;
  1411.   case 1:
  1412.   setups();
  1413.   memcpy(zone1pattern, longstreakspattern, 24);
  1414.     zone1Function = 15;
  1415.     Function1 = 15;
  1416.     break;
  1417.   case 2:
  1418.   setups();
  1419.   memcpy(zone2pattern, longstreakspattern, 24);
  1420.     zone2Function = 15;
  1421.     Function2 = 15;
  1422.     break;
  1423.   case 3:
  1424.   setups();
  1425.   memcpy(zone3pattern, longstreakspattern, 24);
  1426.     zone3Function = 15;
  1427.     Function3 = 15;
  1428.     break;
  1429.   case 4:
  1430.   setups();
  1431.   memcpy(zone4pattern, longstreakspattern, 24);
  1432.     zone4Function = 15;
  1433.     Function4 = 15;
  1434.     break;  
  1435.   }
  1436.   zoneOn();
  1437. }
  1438.  
  1439. void shortstreakZone() {
  1440.   long int time = millis();
  1441.   long int timer2 = time + 3500;
  1442.   switch(zoneSetup){
  1443.   case 0:
  1444.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1445.     break;
  1446.   case 1:
  1447.     setups();
  1448.   memcpy(zone1pattern, shortstreakspattern, 24);
  1449.     zone1Function = 16;
  1450.     Function1 = 16;
  1451.     break;
  1452.   case 2:
  1453.   setups();
  1454.   memcpy(zone2pattern, shortstreakspattern, 24);
  1455.     zone2Function = 16;
  1456.     Function2 = 16;
  1457.     break;
  1458.   case 3:
  1459.   setups();
  1460.   memcpy(zone3pattern, shortstreakspattern, 24);
  1461.     zone3Function = 16;
  1462.     Function3 = 16;
  1463.     break;
  1464.   case 4:
  1465.   setups();
  1466.   memcpy(zone4pattern, shortstreakspattern, 24);
  1467.     zone4Function = 16;
  1468.     Function4 = 16;
  1469.     break;  
  1470.   }
  1471.   zoneOn();
  1472. }
  1473.  
  1474. void diamondfadeZone() {
  1475.   long int time = millis();
  1476.   long int timer2 = time + 3500;
  1477.   switch(zoneSetup){
  1478.   case 0:
  1479.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1480.     break;
  1481.   case 1:
  1482.   setups();
  1483.   memcpy(zone1pattern, diamondfadepattern, 24);
  1484.     zone1Function = 17;
  1485.     Function1 = 17;
  1486.     break;
  1487.   case 2:
  1488.   setups();
  1489.   memcpy(zone2pattern, diamondfadepattern, 24);
  1490.     zone2Function = 17;
  1491.     Function2 = 17;
  1492.     break;
  1493.   case 3:
  1494.   setups();
  1495.   memcpy(zone3pattern, diamondfadepattern, 24);
  1496.     zone3Function = 17;
  1497.     Function3 = 17;
  1498.     break;
  1499.   case 4:
  1500.   setups();
  1501.   memcpy(zone4pattern, diamondfadepattern, 24);
  1502.     zone4Function = 17;
  1503.     Function4 = 17;
  1504.     break;  
  1505.   }
  1506.   zoneOn();
  1507. }
  1508.  
  1509. void customlazerZone() {
  1510.   long int time = millis();
  1511.   long int timer2 = time + 3500;
  1512.   switch(zoneSetup){
  1513.   case 0:
  1514.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1515.     break;
  1516.   case 1:
  1517.     setups();
  1518.     zone1Function = 18;
  1519.     Function1 = 18;
  1520.     memcpy(zone1pattern, lazer, 24);
  1521.     break;
  1522.   case 2:
  1523.     setups();
  1524.     zone2Function = 18;
  1525.     Function2 = 18;
  1526.     memcpy(zone2pattern, lazer, 24);
  1527.     break;
  1528.   case 3:
  1529.     setups();
  1530.     zone3Function = 18;
  1531.     Function3 = 18;
  1532.     memcpy(zone3pattern, lazer, 24);
  1533.     break;
  1534.   case 4:
  1535.     setups();
  1536.     zone4Function = 18;
  1537.     Function4 = 18;
  1538.     memcpy(zone4pattern, lazer, 24);
  1539.     break;  
  1540.   }
  1541.   zoneOn();
  1542. }
  1543.  
  1544. void copsZone() {
  1545.   long int time = millis();
  1546.   long int timer2 = time + 3500;
  1547.   switch(zoneSetup){
  1548.   case 0:
  1549.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1550.     break;
  1551.   case 1:
  1552.     setups();
  1553.     memcpy(zone1pattern, copspattern, 24);
  1554.     zone1Function = 19;
  1555.     Function1 = 19;
  1556.     break;
  1557.   case 2:
  1558.   setups();
  1559.     memcpy(zone2pattern, copspattern, 24);
  1560.     zone2Function = 19;
  1561.     Function2 = 19;
  1562.     break;
  1563.   case 3:
  1564.   setups();
  1565.     memcpy(zone3pattern, copspattern, 24);
  1566.     zone3Function = 19;
  1567.     Function3 = 19;
  1568.     break;
  1569.   case 4:
  1570.   setups();
  1571.     memcpy(zone4pattern, copspattern, 24);
  1572.     zone4Function = 19;
  1573.     Function4 = 19;
  1574.     break;  
  1575.   }
  1576.   zoneOn();
  1577. }
  1578.  
  1579. void cops2Zone() {
  1580.   long int time = millis();
  1581.   long int timer2 = time + 3500;
  1582.   switch(zoneSetup){
  1583.   case 0:
  1584.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1585.     break;
  1586.   case 1:
  1587.     setups();
  1588.     memcpy(zone1pattern, copspattern, 24);
  1589.     zone1Function = 20;
  1590.     Function1 = 20;
  1591.     break;
  1592.   case 2:
  1593.     setups();
  1594.     zone2Function = 20;
  1595.     Function2 = 20;
  1596.     memcpy(zone2pattern, copspattern, 24);
  1597.     break;
  1598.   case 3:
  1599.     setups();
  1600.     zone3Function = 20;
  1601.     Function3 = 20;
  1602.     memcpy(zone1pattern, copspattern, 24);
  1603.     break;
  1604.   case 4:
  1605.     setups();
  1606.     zone4Function = 20;
  1607.     Function4 = 20;
  1608.     memcpy(zone1pattern, copspattern, 24);
  1609.     break;  
  1610.   }
  1611.   zoneOn();
  1612. }
  1613.  
  1614. void patriotic1Zone() {
  1615.  
  1616.   long int time = millis();
  1617.   long int timer2 = time + 3500;
  1618.   switch(zoneSetup){
  1619.   case 0:
  1620.     menu.addSplash("  Zone Not Chosen!  \n Please Select Zone \nUsing  Buttons Below\n    Thank you ;)    \n", timer2);  
  1621.     break;
  1622.   case 1:
  1623.     zone1Function = 7;
  1624.     Function1 = 7;
  1625.     break;
  1626.   case 2:
  1627.     zone2Function = 7;
  1628.     Function2 = 7;
  1629.     break;
  1630.   case 3:
  1631.     zone3Function = 7;
  1632.     Function3 = 7;
  1633.     break;
  1634.   case 4:
  1635.     zone4Function = 7;
  1636.     Function4 = 7;
  1637.     break;  
  1638.   }
  1639.   zoneOn();
  1640. }
  1641.  
  1642. // COLOR FUNCTIONS
  1643.  
  1644. void off(){
  1645.   for (byte i=0; i<NUM_LEDS; i++) {
  1646.     if (FunctionForEachPixel (i, 1, 1)) {
  1647.       leds[i].r = 0;
  1648.       leds[i].g = 0;
  1649.       leds[i].b = 0;
  1650.     }
  1651.   }
  1652. }
  1653.  
  1654. void custom(){
  1655.   for(int i = 0; i < NUM_LEDS; i++){
  1656.     const unsigned int idx = ( i % 24);
  1657.     if (FunctionForEachPixel (i, idx, 2)) {  
  1658.       leds[i].setRGB( zRed, zGreen, zBlue);
  1659.     }  
  1660.   }
  1661. }
  1662.  
  1663. void white(){
  1664.   for(int i = 0; i < NUM_LEDS; i++){
  1665.     const unsigned int idx = ( i % 24);
  1666.     if (FunctionForEachPixel (i, idx, 3)) {  
  1667.       leds[i].setRGB( 255, 244, 244);
  1668.     }  
  1669.   }
  1670. }
  1671.  
  1672. void green(){
  1673.   for(int i = 0; i < NUM_LEDS; i++){
  1674.     const unsigned int idx = ( i % 24);
  1675.     if (FunctionForEachPixel (i, idx, 4)) {  
  1676.       leds[i].setRGB( 0, 255, 0);
  1677.     }  
  1678.   }
  1679. }
  1680.  
  1681.  
  1682. void red(){
  1683.   for(int i = 0; i < NUM_LEDS; i++){
  1684.     const unsigned int idx = ( i % 24);
  1685.     if (FunctionForEachPixel (i, idx, 5)) {  
  1686.       leds[i].setRGB( 255, 0, 0);
  1687.     }  
  1688.   }
  1689. }
  1690.  
  1691.  
  1692. void blue(){
  1693.   for(int i = 0; i < NUM_LEDS; i++){
  1694.     const unsigned int idx = ( i % 24);
  1695.     if (FunctionForEachPixel (i, idx, 6)) {  
  1696.       leds[i].setRGB( 0, 0, 255);
  1697.     }  
  1698.   }
  1699. }
  1700.  
  1701. void yellow(){
  1702.   for(int i = 0; i < NUM_LEDS; i++){
  1703.     const unsigned int idx = ( i % 24);
  1704.     if (FunctionForEachPixel (i, idx, 7)) {  
  1705.       leds[i].setRGB( 255, 175, 0);
  1706.     }  
  1707.   }
  1708. }
  1709.  
  1710. void orange(){
  1711.   for(int i = 0; i < NUM_LEDS; i++){
  1712.     const unsigned int idx = ( i % 24);
  1713.     if (FunctionForEachPixel (i, idx, 8)) {  
  1714.       leds[i].setRGB( 255, 40, 0);
  1715.     }  
  1716.   }
  1717. }
  1718.  
  1719. void pink(){
  1720.   for(int i = 0; i < NUM_LEDS; i++){
  1721.     const unsigned int idx = ( i % 24);
  1722.     if (FunctionForEachPixel (i, idx, 9)) {  
  1723.       leds[i].setRGB( 255, 0, 40);
  1724.     }  
  1725.   }
  1726. }
  1727. void purple(){
  1728.   for(int i = 0; i < NUM_LEDS; i++){
  1729.     const unsigned int idx = ( i % 24);
  1730.     if (FunctionForEachPixel (i, idx, 10)) {  
  1731.       leds[i].setRGB( 85, 0, 85);
  1732.     }  
  1733.   }
  1734. }
  1735. void marine(){
  1736.   for(int i = 0; i < NUM_LEDS; i++){
  1737.     const unsigned int idx = ( i % 24);
  1738.     if (FunctionForEachPixel (i, idx, 11)) {  
  1739.       leds[i].setRGB( 0, 255, 200);
  1740.     }  
  1741.   }
  1742. }
  1743. void grassgreen(){
  1744.   for(int i = 0; i < NUM_LEDS; i++){
  1745.     const unsigned int idx = ( i % 24);
  1746.     if (FunctionForEachPixel (i, idx, 12)) {  
  1747.       leds[i].setRGB( 60, 255, 0);
  1748.     }  
  1749.   }
  1750. }
  1751.  
  1752. void rainbow() {
  1753.   for(int i = 0 ; i < NUM_LEDS; i++){
  1754.     const unsigned int idx = ( i % 24);
  1755.     if (FunctionForEachPixel (i, idx, 13)) {
  1756.       leds[i] = CHSV(zonePattern,255,255);  
  1757.     }  
  1758.   }    
  1759. }
  1760.  
  1761. void rainbowfade() {
  1762.   for(int i = 0; i < NUM_LEDS; i++){
  1763.     const unsigned int idx = ( i % 24);
  1764.     if (FunctionForEachPixel (i, idx, 14)) {  
  1765.       leds[i] = CHSV(zonePattern, 255, 255);
  1766.     }  
  1767.   }    
  1768. }
  1769.  
  1770. void longstreaks() {
  1771.   for(int i = 0; i < NUM_LEDS; i++){
  1772.     const unsigned int idx = ( i % 24);
  1773.  
  1774.     if (FunctionForEachPixel (i, idx, 15)) {
  1775.  
  1776.       leds[i].r = zRed;
  1777.       leds[i].b = zBlue;
  1778.       leds[i].g = zGreen;
  1779.  
  1780.       leds[i].nscale8_video(zonePattern);
  1781.     }  
  1782.   }
  1783. }
  1784.  
  1785. void shortstreaks() {
  1786.   for(int i = 0; i < NUM_LEDS; i++){
  1787.     const unsigned int idx = ( i % 24);
  1788.  
  1789.     if (FunctionForEachPixel (i, idx, 16)) {
  1790.  
  1791.       leds[i].r = zRed;
  1792.       leds[i].b = zBlue;
  1793.       leds[i].g = zGreen;
  1794.  
  1795.       leds[i].nscale8_video(zonePattern);
  1796.     }  
  1797.   }
  1798. }
  1799.  
  1800. void diamondfade() {
  1801.   for(int i = 0; i < NUM_LEDS; i++){
  1802.     const unsigned int idx = ( i % 24);
  1803.  
  1804.     if (FunctionForEachPixel (i, idx, 17)) {
  1805.  
  1806.       leds[i].r = zRed;
  1807.       leds[i].b = zBlue;
  1808.       leds[i].g = zGreen;
  1809.  
  1810.       leds[i].nscale8_video(zonePattern);
  1811.     }  
  1812.   }
  1813. }
  1814.  
  1815.  
  1816. void customlazer() {
  1817.  
  1818.   for(int i = 0; i < NUM_LEDS; i++){
  1819.     const unsigned int idx = ( i % 24);
  1820.  
  1821.     if (FunctionForEachPixel (i, idx, 18)) {
  1822.  
  1823.       leds[i].r = zRed;
  1824.       leds[i].b = zBlue;
  1825.       leds[i].g = zGreen;
  1826.  
  1827.       leds[i].nscale8_video(zonePattern);
  1828.     }  
  1829.   }
  1830. }
  1831.  
  1832. void cops() {
  1833.   unsigned long flasherTime = millis();
  1834.   static boolean flashflag = 0;
  1835.   int color = 0;
  1836.   int color2 = 0;
  1837.  
  1838.   for(int i = 0; i < NUM_LEDS; i++){
  1839.     const unsigned int idx = ( i % 24);
  1840.     if (FunctionForEachPixel (i, idx, 19)) {  
  1841.       leds[i] = CHSV(zonePattern, 255, 255);
  1842.     }
  1843.  
  1844.     if(flasherTime - flasherstart >= flasherinterval){
  1845.       flashflag =! flashflag;
  1846.       flasherstart = flasherTime;
  1847.     }
  1848.  
  1849.     if(flashflag == 0){
  1850.       color = 255;
  1851.       color2 = 0;
  1852.     }
  1853.     else {
  1854.       color = 0;
  1855.       color2 = 255;
  1856.     }
  1857.  
  1858.  
  1859.     if (i <= LastZone1Pixel &&  Function1 == 19){
  1860.       leds[4].setRGB(color, color, color);
  1861.       leds[5].setRGB(color, color, color);
  1862.       leds[6].setRGB(color, color, color);
  1863.       leds[24].setRGB(color2, color2, color2);
  1864.       leds[25].setRGB(color2, color2, color2);
  1865.       leds[26].setRGB(color2, color2, color2);
  1866.     }//function 2 is the selected function for zone 1
  1867.     if (i > LastZone1Pixel && i <= LastZone2Pixel && Function2 == 19) {
  1868.       leds[34].setRGB(color, color, color);
  1869.       leds[35].setRGB(color, color, color);
  1870.       leds[36].setRGB(color, color, color);
  1871.       leds[54].setRGB(color2, color2, color2);
  1872.       leds[55].setRGB(color2, color2, color2);
  1873.       leds[56].setRGB(color2, color2, color2);
  1874.     }
  1875.     if (i > LastZone2Pixel && i <= LastZone3Pixel && Function3 == 19) {
  1876.       leds[64].setRGB(color, color, color);
  1877.       leds[65].setRGB(color, color, color);
  1878.       leds[66].setRGB(color, color, color);
  1879.       leds[84].setRGB(color2, color2, color2);
  1880.       leds[85].setRGB(color2, color2, color2);
  1881.       leds[86].setRGB(color2, color2, color2);
  1882.     }
  1883.     if (i > LastZone3Pixel && i <= LastZone4Pixel && Function4 == 19) {
  1884.       leds[94].setRGB(color, color, color);
  1885.       leds[95].setRGB(color, color, color);
  1886.       leds[96].setRGB(color, color, color);
  1887.       leds[114].setRGB(color2, color2, color2);
  1888.       leds[115].setRGB(color2, color2, color2);
  1889.       leds[116].setRGB(color2, color2, color2);
  1890.     }
  1891.   }  
  1892. }
  1893.  
  1894. void cops1() {
  1895.   unsigned long flasherTime1 = millis();
  1896.   static boolean flashflagg = 0;
  1897.  
  1898.   int color1 = 0;
  1899.   int color12 = 0;
  1900.  
  1901.   byte a = LastZone1Pixel/2;
  1902.   byte b = ((LastZone2Pixel - LastZone1Pixel) / 2) + LastZone1Pixel;
  1903.   byte c = ((LastZone3Pixel - LastZone2Pixel) / 2) + LastZone2Pixel;
  1904.   byte d = ((LastZone4Pixel - LastZone3Pixel) / 2) + LastZone3Pixel;
  1905.  
  1906.   for(int i = 0; i <= a; i++) {
  1907.   FunctionForEachPixel (i, 1, 20);
  1908.  
  1909.   if(flasherTime1 - flasherstart1 >= 150){
  1910.       flashflagg =! flashflagg;
  1911.       flasherstart1 = flasherTime1;
  1912.     }
  1913.  
  1914.     if(flashflagg == 0){
  1915.       color1 = 255;
  1916.       color12 = 0;
  1917.     }
  1918.     else {
  1919.       color1 = 0;
  1920.       color12 = 255;
  1921.     }
  1922.   }
  1923.  
  1924.   const unsigned int idx = 2;
  1925.  
  1926.     for(int j = 0; j <= a; j++) {
  1927.       if (FunctionForEachPixel (j, idx, 20)) {
  1928.         leds[j].setRGB(color1, 0, color12);
  1929.       }
  1930.     }
  1931.     for(int j = a + 1; j <= LastZone1Pixel; j++) {
  1932.       if (FunctionForEachPixel (j, idx, 20)) {
  1933.         leds[j].setRGB(color12, 0, color1);
  1934.       }
  1935.     }
  1936.     for(int j = LastZone1Pixel + 1; j <= b; j++) {
  1937.       if (FunctionForEachPixel (j, idx, 20)) {
  1938.         leds[j].setRGB(color1, 0, color12);
  1939.       }
  1940.     }
  1941.     for(int j = b + 1; j <= LastZone2Pixel; j++) {
  1942.       if (FunctionForEachPixel (j, idx, 20)) {
  1943.       leds[j].setRGB(color12, 0, color1);
  1944.     }
  1945.     }
  1946.     for(int j = LastZone2Pixel + 1 ; j <= c; j++) {
  1947.       if (FunctionForEachPixel (j, idx, 20)) {
  1948.         leds[j].setRGB(color1, 0, color12);
  1949.       }
  1950.     }
  1951.     for(int j = c + 1; j <= LastZone3Pixel; j++) {
  1952.       if (FunctionForEachPixel (j, idx, 20)) {
  1953.         leds[j].setRGB(color12, 0, color1);
  1954.       }
  1955.     }
  1956.     for(int j = LastZone3Pixel + 1; j <= d; j++) {
  1957.       if (FunctionForEachPixel (j, idx, 20)) {
  1958.         leds[j].setRGB(color1, 0, color12);
  1959.       }
  1960.     }
  1961.     for(int j = d + 1; j <= LastZone4Pixel; j++) {
  1962.       if (FunctionForEachPixel (j, idx, 20)) {
  1963.         leds[j].setRGB(color12, 0, color1);
  1964.       }
  1965.     }
  1966.   }
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975. void patriotic1() {
  1976. }
  1977.  
  1978.  
  1979.  
  1980. void strobing() {
  1981.  
  1982. }
Advertisement
Add Comment
Please, Sign In to add comment