Guest User

FunkBox-LEDStickman-FastLED

a guest
Aug 20th, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.38 KB | None | 0 0
  1. /*------------------------------------#
  2. #----- FASTSPI2 EFFECTS EXAMPLES -----#
  3. #-------------- v0.51 ----------------#
  4. #------------ teldredge --------------#
  5. #-------- www.funkboxing.com ---------#
  6. #------ [email protected] ------#
  7. #-------------------------------------#
  8. ### THESE EFFECTS ARE MOSTLY DESIGNED FOR A LOOP/RING OF LEDS
  9. ### BUT PLENTY USEFUL FOR OTHER CONFIGURATIONS
  10. ### RECENT CHANGES v0.51
  11. -ADDED SOFTWARE SERIAL FOR BLUETOOTH CONTROL
  12. -ADDED (z) SHOW LED COMMAND (FOR BETTER SERIAL CONTROL)
  13. -ADDED SET (a)ll LEDS TO COLOR HSV (0-255)
  14. -ADDED (c)lear FUNCTION
  15. -ADDED (v) SET INDIVIDUAL LED HSV FUNCTION
  16. -ADDED (Q)UERY VERSION NUMBER FUNCTION
  17. ### NOTES
  18. -MAKE SURE YOU ARE USING FAST_SPI RC3 OR LATER
  19. -THIS IS AN EXAMPLE LIBRARY SO YOU'LL PRABALY WANT TO EDIT TO DO ANYTHING USEFUL WITH IT
  20. -GOTO FUNKBOXING FAST_SPI2 COMMENTS PAGE FOR HELP
  21. -DEMO MODE BLOCKS SERIAL COMMANDS
  22. ### LICENSE:::USE FOR WHATEVER YOU WANT, WHENEVER YOU WANT, HOWEVER YOU WANT, WHYEVER YOU WANT
  23. ### BUT YOU MUST YODEL ONCE FOR FREEDOM AND MAYBE DONATE TO SOMETHING WORTHWHILE
  24.  
  25. |-----------------------------------------------------|
  26. | |
  27. | FROM THE FAST_SPI2 EXAMPLE FILE |
  28. | |
  29. |----------------------------------------------------*/
  30. // Uncomment this line if you have any interrupts that are changing pins - this causes the library to be a little bit more cautious
  31. // #define FAST_SPI_INTERRUPTS_WRITE_PINS 1
  32.  
  33. // Uncomment this line to force always using software, instead of hardware, SPI (why?)
  34. // #define FORCE_SOFTWARE_SPI 1
  35.  
  36. // Uncomment this line if you want to talk to DMX controllers
  37. // #define FASTSPI_USE_DMX_SIMPLE 1
  38. //-----------------------------------------------------
  39.  
  40. #include <SoftwareSerial.h>
  41. #include <FastLED.h>
  42. #include "Timer.h"
  43.  
  44. Timer time;
  45. int newmode = 2;
  46.  
  47. #define VERSION_NUMBER 0.51
  48.  
  49. //---LED SETUP STUFF
  50. #define LED_COUNT 25 //FOR TESTING w/ SIGN
  51. #define NUM_LEDS 25
  52. #define DATA_PIN 12
  53. #define CLOCK_PIN 13
  54. #define NUM_LEDSPERROW 25
  55.  
  56. long btnDnTime; // time the button was pressed down
  57. long btnUpTime; // time the button was released
  58. #define holdTime 3000 //used to time button hold for special function
  59. //#define buttonPin 3 //Default button pin, Pin 21 and 22 used for SPI
  60. int pbIn = 3; // Interrupt 0 is on DIGITAL PIN 2!
  61. volatile boolean buttonstate = 0; // The input state toggle NOT PRESSED = 0
  62.  
  63.  
  64. int BOTTOM_INDEX = 0;
  65. int TOP_INDEX = int(LED_COUNT/2);
  66. int EVENODD = LED_COUNT%2;
  67. struct CRGB leds[LED_COUNT];
  68. int ledsX[LED_COUNT][3]; //-ARRAY FOR COPYING WHATS IN THE LED STRIP CURRENTLY (FOR CELL-AUTOMATA, MARCH, ETC)
  69. int ledMode = 2; //- USES TIMER 30 seconds
  70. //volatile int ledMode = 888; //-START IN DEMO MODE
  71. //int ledMode = 6; //-MODE TESTING
  72.  
  73. int thisdelay = 20; //-FX LOOPS DELAY VAR
  74. int thisstep = 10; //-FX LOOPS DELAY VAR
  75. int thishue = 0; //-FX LOOPS DELAY VAR
  76. int thissat = 255; //-FX LOOPS DELAY VAR
  77. int max_bright = 165; //-SET MAX BRIGHTNESS TO 1/4
  78.  
  79. int thisindex = 0; //-SET SINGLE LED VAR
  80. int thisRED = 0;
  81. int thisGRN = 0;
  82. int thisBLU = 0;
  83.  
  84. //---SERIAL/SOFTWARE SERIAL SETUP STUFF
  85. #define SERIAL_BAUDRATE 9600
  86.  
  87.  
  88. //---LED FX VARS
  89. int idex = 0; //-LED INDEX (0 to LED_COUNT-1
  90. int ihue = 0; //-HUE (0-255)
  91. int ibright = 0; //-BRIGHTNESS (0-255)
  92. int isat = 0; //-SATURATION (0-255)
  93. int bouncedirection = 0; //-SWITCH FOR COLOR BOUNCE (0-1)
  94. float tcount = 0.0; //-INC VAR FOR SIN LOOPS
  95. int lcount = 0; //-ANOTHER COUNTING VAR
  96.  
  97.  
  98. //------------------------------------- UTILITY FXNS --------------------------------------
  99. //---SET THE COLOR OF A SINGLE RGB LED
  100. void set_color_led(int adex, int cred, int cgrn, int cblu) {
  101. leds[adex].setRGB( cred, cgrn, cblu);
  102. }
  103.  
  104. //---FIND INDEX OF HORIZONAL OPPOSITE LED
  105. int horizontal_index(int i) {
  106. //-ONLY WORKS WITH INDEX < TOPINDEX
  107. if (i == BOTTOM_INDEX) {return BOTTOM_INDEX;}
  108. if (i == TOP_INDEX && EVENODD == 1) {return TOP_INDEX + 1;}
  109. if (i == TOP_INDEX && EVENODD == 0) {return TOP_INDEX;}
  110. return LED_COUNT - i;
  111. }
  112.  
  113. //---FIND INDEX OF ANTIPODAL OPPOSITE LED
  114. int antipodal_index(int i) {
  115. int iN = i + TOP_INDEX;
  116. if (i >= TOP_INDEX) {iN = ( i + TOP_INDEX ) % LED_COUNT; }
  117. return iN;
  118. }
  119.  
  120. //---FIND ADJACENT INDEX CLOCKWISE
  121. int adjacent_cw(int i) {
  122. int r;
  123. if (i < LED_COUNT - 1) {r = i + 1;}
  124. else {r = 0;}
  125. return r;
  126. }
  127.  
  128. //---FIND ADJACENT INDEX COUNTER-CLOCKWISE
  129. int adjacent_ccw(int i) {
  130. int r;
  131. if (i > 0) {r = i - 1;}
  132. else {r = LED_COUNT - 1;}
  133. return r;
  134. }
  135.  
  136. void copy_led_array(){
  137. for(int i = 0; i < LED_COUNT; i++ ) {
  138. ledsX[i][0] = leds[i].r;
  139. ledsX[i][1] = leds[i].g;
  140. ledsX[i][2] = leds[i].b;
  141. }
  142. }
  143.  
  144.  
  145. //------------------------LED EFFECT FUNCTIONS------------------------
  146. void one_color_all(int cred, int cgrn, int cblu) { //-SET ALL LEDS TO ONE COLOR
  147. for(int i = 0 ; i < LED_COUNT; i++ ) {
  148. /*****************************************************************************/
  149. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  150. /*****************************************************************************/
  151. leds[i].setRGB( cred, cgrn, cblu);
  152. }
  153. /******************** END OF FUNCTION EFFECT *****************************/
  154. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  155. /******************** END OF FUNCTION EFFECT *****************************/
  156. }
  157.  
  158. void one_color_allHSV(int ahue) { //-SET ALL LEDS TO ONE COLOR (HSV)
  159. for(int i = 0 ; i < LED_COUNT; i++ ) {
  160. /*****************************************************************************/
  161. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  162. /*****************************************************************************/
  163. leds[i] = CHSV(ahue, thissat, 255);
  164. }
  165. /******************** END OF FUNCTION EFFECT *****************************/
  166. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  167. /******************** END OF FUNCTION EFFECT *****************************/
  168. }
  169.  
  170. void rainbow_fade() { //-m2-FADE ALL LEDS THROUGH HSV RAINBOW
  171. ihue++;
  172. if (ihue > 255) {ihue = 0;}
  173. for(int idex = 0 ; idex < LED_COUNT; idex++ ) {
  174. /*****************************************************************************/
  175. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  176. /*****************************************************************************/
  177. leds[idex] = CHSV(ihue, thissat, 255);
  178. }
  179. LEDS.show();
  180. FastLED.delay(thisdelay);
  181. /******************** END OF FUNCTION EFFECT *****************************/
  182. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  183. /******************** END OF FUNCTION EFFECT *****************************/
  184. }
  185.  
  186. void rainbow_loop() { //-m3-LOOP HSV RAINBOW
  187. idex++;
  188. /*****************************************************************************/
  189. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  190. /*****************************************************************************/
  191. ihue = ihue + thisstep;
  192. if (idex >= LED_COUNT) {idex = 0;}
  193. if (ihue > 255) {ihue = 0;}
  194. leds[idex] = CHSV(ihue, thissat, 255);
  195. LEDS.show();
  196. FastLED.delay(thisdelay);
  197. /******************** END OF FUNCTION EFFECT *****************************/
  198. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  199. /******************** END OF FUNCTION EFFECT *****************************/
  200. }
  201.  
  202. void random_burst() { //-m4-RANDOM INDEX/COLOR
  203. idex = random(0, LED_COUNT);
  204. ihue = random(0, 255);
  205. /*****************************************************************************/
  206. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  207. /*****************************************************************************/
  208. leds[idex] = CHSV(ihue, thissat, 255);
  209. LEDS.show();
  210. FastLED.delay(thisdelay);
  211. /******************** END OF FUNCTION EFFECT *****************************/
  212. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  213. /******************** END OF FUNCTION EFFECT *****************************/
  214. }
  215.  
  216. void color_bounce() { //-m5-BOUNCE COLOR (SINGLE LED)
  217. if (bouncedirection == 0) {
  218. idex = idex + 1;
  219. if (idex == LED_COUNT) {
  220. bouncedirection = 1;
  221. idex = idex - 1;
  222. }
  223. }
  224. if (bouncedirection == 1) {
  225. idex = idex - 1;
  226. if (idex == 0) {
  227. bouncedirection = 0;
  228. }
  229. }
  230. for(int i = 0; i < LED_COUNT; i++ ) {
  231. /*****************************************************************************/
  232. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  233. /*****************************************************************************/
  234. if (i == idex) {leds[i] = CHSV(thishue, thissat, 255);}
  235. else {leds[i] = CHSV(0, 0, 0);}
  236. }
  237. LEDS.show();
  238. FastLED.delay(thisdelay);
  239. /******************** END OF FUNCTION EFFECT *****************************/
  240. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  241. /******************** END OF FUNCTION EFFECT *****************************/
  242. }
  243.  
  244. void color_bounceFADE() { //-m6-BOUNCE COLOR (SIMPLE MULTI-LED FADE)
  245. if (bouncedirection == 0) {
  246. idex = idex + 1;
  247. if (idex == LED_COUNT) {
  248. bouncedirection = 1;
  249. idex = idex - 1;
  250. }
  251. }
  252. if (bouncedirection == 1) {
  253. idex = idex - 1;
  254. if (idex == 0) {
  255. bouncedirection = 0;
  256. }
  257. }
  258. int iL1 = adjacent_cw(idex);
  259. int iL2 = adjacent_cw(iL1);
  260. int iL3 = adjacent_cw(iL2);
  261. int iR1 = adjacent_ccw(idex);
  262. int iR2 = adjacent_ccw(iR1);
  263. int iR3 = adjacent_ccw(iR2);
  264. for(int i = 0; i < LED_COUNT; i++ ) {
  265. /*****************************************************************************/
  266. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  267. /*****************************************************************************/
  268. if (i == idex) {leds[i] = CHSV(thishue, thissat, 255);}
  269. else if (i == iL1) {leds[i] = CHSV(thishue, thissat, 150);}
  270. else if (i == iL2) {leds[i] = CHSV(thishue, thissat, 80);}
  271. else if (i == iL3) {leds[i] = CHSV(thishue, thissat, 20);}
  272. else if (i == iR1) {leds[i] = CHSV(thishue, thissat, 150);}
  273. else if (i == iR2) {leds[i] = CHSV(thishue, thissat, 80);}
  274. else if (i == iR3) {leds[i] = CHSV(thishue, thissat, 20);}
  275. else {leds[i] = CHSV(0, 0, 0);}
  276. }
  277. LEDS.show();
  278. FastLED.delay(thisdelay);
  279. /******************** END OF FUNCTION EFFECT *****************************/
  280. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  281. /******************** END OF FUNCTION EFFECT *****************************/
  282. }
  283.  
  284. void ems_lightsONE() { //-m7-EMERGENCY LIGHTS (TWO COLOR SINGLE LED)
  285. idex++;
  286. if (idex >= LED_COUNT) {idex = 0;}
  287. int idexR = idex;
  288. int idexB = antipodal_index(idexR);
  289. int thathue = (thishue + 160) % 255;
  290. for(int i = 0; i < LED_COUNT; i++ ) {
  291. /*****************************************************************************/
  292. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  293. /*****************************************************************************/
  294. if (i == idexR) {leds[i] = CHSV(thishue, thissat, 255);}
  295. else if (i == idexB) {leds[i] = CHSV(thathue, thissat, 255);}
  296. else {leds[i] = CHSV(0, 0, 0);}
  297. }
  298. LEDS.show();
  299. FastLED.delay(thisdelay);
  300. /******************** END OF FUNCTION EFFECT *****************************/
  301. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  302. /******************** END OF FUNCTION EFFECT *****************************/
  303. }
  304.  
  305. void ems_lightsALL() { //-m8-EMERGENCY LIGHTS (TWO COLOR SOLID)
  306. idex++;
  307. if (idex >= LED_COUNT) {idex = 0;}
  308. int idexR = idex;
  309. int idexB = antipodal_index(idexR);
  310. int thathue = (thishue + 160) % 255;
  311. leds[idexR] = CHSV(thishue, thissat, 255);
  312. leds[idexB] = CHSV(thathue, thissat, 255);
  313. /*****************************************************************************/
  314. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  315. /*****************************************************************************/
  316. LEDS.show();
  317. FastLED.delay(thisdelay);
  318. /******************** END OF FUNCTION EFFECT *****************************/
  319. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  320. /******************** END OF FUNCTION EFFECT *****************************/
  321. }
  322.  
  323. void flicker() { //-m9-FLICKER EFFECT
  324. int random_bright = random(0,255);
  325. int random_delay = random(10,75);
  326. int random_bool = random(0,random_bright);
  327. if (random_bool < 10) {
  328. for(int i = 0 ; i < LED_COUNT; i++ ) {
  329. /*****************************************************************************/
  330. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  331. /*****************************************************************************/
  332. leds[i] = CHSV(thishue, thissat, random_bright);
  333. }
  334. LEDS.show();
  335. FastLED.delay(random_delay);
  336. }
  337. /******************** END OF FUNCTION EFFECT *****************************/
  338. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  339. /******************** END OF FUNCTION EFFECT *****************************/
  340. }
  341.  
  342. void pulse_one_color_all() { //-m10-PULSE BRIGHTNESS ON ALL LEDS TO ONE COLOR
  343. if (bouncedirection == 0) {
  344. ibright++;
  345. if (ibright >= 255) {bouncedirection = 1;}
  346. }
  347. if (bouncedirection == 1) {
  348. ibright = ibright - 1;
  349. if (ibright <= 1) {bouncedirection = 0;}
  350. }
  351. for(int idex = 0 ; idex < LED_COUNT; idex++ ) {
  352. /*****************************************************************************/
  353. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  354. /*****************************************************************************/
  355. leds[idex] = CHSV(thishue, thissat, ibright);
  356. }
  357. LEDS.show();
  358. FastLED.delay(thisdelay);
  359. /******************** END OF FUNCTION EFFECT *****************************/
  360. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  361. /******************** END OF FUNCTION EFFECT *****************************/
  362. }
  363.  
  364. void pulse_one_color_all_rev() { //-m11-PULSE SATURATION ON ALL LEDS TO ONE COLOR
  365. if (bouncedirection == 0) {
  366. isat++;
  367. if (isat >= 255) {bouncedirection = 1;}
  368. }
  369. if (bouncedirection == 1) {
  370. isat = isat - 1;
  371. if (isat <= 1) {bouncedirection = 0;}
  372. }
  373. for(int idex = 0 ; idex < LED_COUNT; idex++ ) {
  374. /*****************************************************************************/
  375. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  376. /*****************************************************************************/
  377. leds[idex] = CHSV(thishue, isat, 255);
  378. }
  379. LEDS.show();
  380. FastLED.delay(thisdelay);
  381. /******************** END OF FUNCTION EFFECT *****************************/
  382. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  383. /******************** END OF FUNCTION EFFECT *****************************/
  384. }
  385.  
  386. void fade_vertical() { //-m12-FADE 'UP' THE LOOP
  387. idex++;
  388. if (idex > TOP_INDEX) {idex = 0;}
  389. int idexA = idex;
  390. int idexB = horizontal_index(idexA);
  391. ibright = ibright + 10;
  392. if (ibright > 255) {ibright = 0;}
  393. leds[idexA] = CHSV(thishue, thissat, ibright);
  394. leds[idexB] = CHSV(thishue, thissat, ibright);
  395. /*****************************************************************************/
  396. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  397. /*****************************************************************************/
  398. LEDS.show();
  399. FastLED.delay(thisdelay);
  400. /******************** END OF FUNCTION EFFECT *****************************/
  401. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  402. /******************** END OF FUNCTION EFFECT *****************************/
  403. }
  404.  
  405. void random_red() { //QUICK 'N DIRTY RANDOMIZE TO GET CELL AUTOMATA STARTED
  406. int temprand;
  407. for(int i = 0; i < LED_COUNT; i++ ) {
  408. /*****************************************************************************/
  409. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  410. /*****************************************************************************/
  411. temprand = random(0,100);
  412. if (temprand > 50) {leds[i].r = 255;}
  413. if (temprand <= 50) {leds[i].r = 0;}
  414. leds[i].b = 0; leds[i].g = 0;
  415. }
  416. LEDS.show();
  417. /******************** END OF FUNCTION EFFECT *****************************/
  418. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  419. /******************** END OF FUNCTION EFFECT *****************************/
  420. }
  421.  
  422. void rule30() { //-m13-1D CELLULAR AUTOMATA - RULE 30 (RED FOR NOW)
  423. if (bouncedirection == 0) {
  424. random_red();
  425. bouncedirection = 1;
  426. }
  427. copy_led_array();
  428. int iCW;
  429. int iCCW;
  430. int y = 100;
  431. for(int i = 0; i < LED_COUNT; i++ ) {
  432. /*****************************************************************************/
  433. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  434. /*****************************************************************************/
  435. iCW = adjacent_cw(i);
  436. iCCW = adjacent_ccw(i);
  437. if (ledsX[iCCW][0] > y && ledsX[i][0] > y && ledsX[iCW][0] > y) {leds[i].r = 0;}
  438. if (ledsX[iCCW][0] > y && ledsX[i][0] > y && ledsX[iCW][0] <= y) {leds[i].r = 0;}
  439. if (ledsX[iCCW][0] > y && ledsX[i][0] <= y && ledsX[iCW][0] > y) {leds[i].r = 0;}
  440. if (ledsX[iCCW][0] > y && ledsX[i][0] <= y && ledsX[iCW][0] <= y) {leds[i].r = 255;}
  441. if (ledsX[iCCW][0] <= y && ledsX[i][0] > y && ledsX[iCW][0] > y) {leds[i].r = 255;}
  442. if (ledsX[iCCW][0] <= y && ledsX[i][0] > y && ledsX[iCW][0] <= y) {leds[i].r = 255;}
  443. if (ledsX[iCCW][0] <= y && ledsX[i][0] <= y && ledsX[iCW][0] > y) {leds[i].r = 255;}
  444. if (ledsX[iCCW][0] <= y && ledsX[i][0] <= y && ledsX[iCW][0] <= y) {leds[i].r = 0;}
  445. }
  446. LEDS.show();
  447. FastLED.delay(thisdelay);
  448. /******************** END OF FUNCTION EFFECT *****************************/
  449. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  450. /******************** END OF FUNCTION EFFECT *****************************/
  451. }
  452.  
  453. void random_march() { //-m14-RANDOM MARCH CCW
  454. copy_led_array();
  455. int iCCW;
  456. leds[0] = CHSV(random(0,255), 255, 255);
  457. for(int idex = 1; idex < LED_COUNT ; idex++ ) {\
  458. /*****************************************************************************/
  459. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  460. /*****************************************************************************/
  461. iCCW = adjacent_ccw(idex);
  462. leds[idex].r = ledsX[iCCW][0];
  463. leds[idex].g = ledsX[iCCW][1];
  464. leds[idex].b = ledsX[iCCW][2];
  465. }
  466. LEDS.show();
  467. FastLED.delay(thisdelay);
  468. /******************** END OF FUNCTION EFFECT *****************************/
  469. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  470. /******************** END OF FUNCTION EFFECT *****************************/
  471. }
  472.  
  473. void rwb_march() { //-m15-R,W,B MARCH CCW
  474. copy_led_array();
  475. int iCCW;
  476. idex++;
  477. if (idex > 2) {idex = 0;}
  478. switch (idex) {
  479. case 0:
  480. leds[0].r = 255;
  481. leds[0].g = 0;
  482. leds[0].b = 0;
  483. break;
  484. case 1:
  485. leds[0].r = 255;
  486. leds[0].g = 255;
  487. leds[0].b = 255;
  488. break;
  489. case 2:
  490. leds[0].r = 0;
  491. leds[0].g = 0;
  492. leds[0].b = 255;
  493. break;
  494. }
  495. for(int i = 1; i < LED_COUNT; i++ ) {
  496. /*****************************************************************************/
  497. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  498. /*****************************************************************************/
  499. iCCW = adjacent_ccw(i);
  500. leds[i].r = ledsX[iCCW][0];
  501. leds[i].g = ledsX[iCCW][1];
  502. leds[i].b = ledsX[iCCW][2];
  503. }
  504. LEDS.show();
  505. FastLED.delay(thisdelay);
  506. /******************** END OF FUNCTION EFFECT *****************************/
  507. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  508. /******************** END OF FUNCTION EFFECT *****************************/
  509. }
  510.  
  511. void radiation() { //-m16-SORT OF RADIATION SYMBOLISH-
  512. int N3 = int(LED_COUNT/3);
  513. int N6 = int(LED_COUNT/6);
  514. int N12 = int(LED_COUNT/12);
  515. /*****************************************************************************/
  516. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  517. /*****************************************************************************/
  518. for(int i = 0; i < N6; i++ ) { //-HACKY, I KNOW...
  519. /*****************************************************************************/
  520. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  521. /*****************************************************************************/
  522. tcount = tcount + .02;
  523. if (tcount > 3.14) {tcount = 0.0;}
  524. ibright = int(sin(tcount)*255);
  525. int j0 = (i + LED_COUNT - N12) % LED_COUNT;
  526. int j1 = (j0+N3) % LED_COUNT;
  527. int j2 = (j1+N3) % LED_COUNT;
  528. leds[j0] = CHSV(thishue, thissat, ibright);
  529. leds[j1] = CHSV(thishue, thissat, ibright);
  530. leds[j2] = CHSV(thishue, thissat, ibright);
  531. }
  532. LEDS.show();
  533. FastLED.delay(thisdelay);
  534. /******************** END OF FUNCTION EFFECT *****************************/
  535. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  536. /******************** END OF FUNCTION EFFECT *****************************/
  537. }
  538.  
  539. void color_loop_vardelay() { //-m17-COLOR LOOP (SINGLE LED) w/ VARIABLE DELAY
  540. idex++;
  541. if (idex > LED_COUNT) {idex = 0;}
  542. int di = abs(TOP_INDEX - idex);
  543. int t = constrain((10/di)*10, 10, 500);
  544. for(int i = 0; i < LED_COUNT; i++ ) {
  545. /*****************************************************************************/
  546. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  547. /*****************************************************************************/
  548. if (i == idex) {
  549. leds[i] = CHSV(0, thissat, 255);
  550. }
  551. else {
  552. leds[i].r = 0; leds[i].g = 0; leds[i].b = 0;
  553. }
  554. }
  555. LEDS.show();
  556. FastLED.delay(t);
  557. /******************** END OF FUNCTION EFFECT *****************************/
  558. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  559. /******************** END OF FUNCTION EFFECT *****************************/
  560. }
  561.  
  562. void white_temps() { //-m18-SHOW A SAMPLE OF BLACK BODY RADIATION COLOR TEMPERATURES
  563. int N9 = int(LED_COUNT/9);
  564. for (int i = 0; i < LED_COUNT; i++ ) {
  565. /*****************************************************************************/
  566. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  567. /*****************************************************************************/
  568. if (i >= 0 && i < N9) {leds[i].r = 255; leds[i].g = 147; leds[i].b = 41;} //-CANDLE - 1900
  569. if (i >= N9 && i < N9*2) {leds[i].r = 255; leds[i].g = 197; leds[i].b = 143;} //-40W TUNG - 2600
  570. if (i >= N9*2 && i < N9*3) {leds[i].r = 255; leds[i].g = 214; leds[i].b = 170;} //-100W TUNG - 2850
  571. if (i >= N9*3 && i < N9*4) {leds[i].r = 255; leds[i].g = 241; leds[i].b = 224;} //-HALOGEN - 3200
  572. if (i >= N9*4 && i < N9*5) {leds[i].r = 255; leds[i].g = 250; leds[i].b = 244;} //-CARBON ARC - 5200
  573. if (i >= N9*5 && i < N9*6) {leds[i].r = 255; leds[i].g = 255; leds[i].b = 251;} //-HIGH NOON SUN - 5400
  574. if (i >= N9*6 && i < N9*7) {leds[i].r = 255; leds[i].g = 255; leds[i].b = 255;} //-DIRECT SUN - 6000
  575. if (i >= N9*7 && i < N9*8) {leds[i].r = 201; leds[i].g = 226; leds[i].b = 255;} //-OVERCAST SKY - 7000
  576. if (i >= N9*8 && i < LED_COUNT) {leds[i].r = 64; leds[i].g = 156; leds[i].b = 255;}//-CLEAR BLUE SKY - 20000
  577. }
  578. LEDS.show();
  579. FastLED.delay(100);
  580. /******************** END OF FUNCTION EFFECT *****************************/
  581. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  582. /******************** END OF FUNCTION EFFECT *****************************/
  583. }
  584.  
  585. void sin_bright_wave() { //-m19-BRIGHTNESS SINE WAVE
  586. for(int i = 0; i < LED_COUNT; i++ ) {
  587. /*****************************************************************************/
  588. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  589. /*****************************************************************************/
  590. tcount = tcount + .1;
  591. if (tcount > 3.14) {tcount = 0.0;}
  592. ibright = int(sin(tcount)*255);
  593. leds[i] = CHSV(thishue, thissat, ibright);
  594. LEDS.show();
  595. FastLED.delay(thisdelay);
  596. }
  597. /******************** END OF FUNCTION EFFECT *****************************/
  598. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  599. /******************** END OF FUNCTION EFFECT *****************************/
  600. }
  601.  
  602. void pop_horizontal() { //-m20-POP FROM LEFT TO RIGHT UP THE RING
  603. int ix;
  604. if (bouncedirection == 0) {
  605. bouncedirection = 1;
  606. ix = idex;
  607. }
  608. else if (bouncedirection == 1) {
  609. bouncedirection = 0;
  610. ix = horizontal_index(idex);
  611. idex++;
  612. if (idex > TOP_INDEX) {idex = 0;}
  613. }
  614. for(int i = 0; i < LED_COUNT; i++ ) {
  615. /*****************************************************************************/
  616. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  617. /*****************************************************************************/
  618. if (i == ix) {
  619. leds[i] = CHSV(thishue, thissat, 255);
  620. }
  621. else {
  622. leds[i].r = 0; leds[i].g = 0; leds[i].b = 0;
  623. }
  624. }
  625. LEDS.show();
  626. FastLED.delay(thisdelay);
  627. /******************** END OF FUNCTION EFFECT *****************************/
  628. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  629. /******************** END OF FUNCTION EFFECT *****************************/
  630. }
  631.  
  632. void quad_bright_curve() { //-m21-QUADRATIC BRIGHTNESS CURVER
  633. int ax;
  634. for(int x = 0; x < LED_COUNT; x++ ) {
  635. /*****************************************************************************/
  636. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  637. /*****************************************************************************/
  638. if (x <= TOP_INDEX) {ax = x;}
  639. else if (x > TOP_INDEX) {ax = LED_COUNT-x;}
  640. int a = 1; int b = 1; int c = 0;
  641. int iquad = -(ax*ax*a)+(ax*b)+c; //-ax2+bx+c
  642. int hquad = -(TOP_INDEX*TOP_INDEX*a)+(TOP_INDEX*b)+c;
  643. ibright = int((float(iquad)/float(hquad))*255);
  644. leds[x] = CHSV(thishue, thissat, ibright);
  645. }
  646. LEDS.show();
  647. FastLED.delay(thisdelay);
  648. /******************** END OF FUNCTION EFFECT *****************************/
  649. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  650. /******************** END OF FUNCTION EFFECT *****************************/
  651. }
  652.  
  653. void flame() { //-m22-FLAMEISH EFFECT
  654. int idelay = random(0,35);
  655. float hmin = 0.1; float hmax = 45.0;
  656. float hdif = hmax-hmin;
  657. int randtemp = random(0,3);
  658. float hinc = (hdif/float(TOP_INDEX))+randtemp;
  659. int ihue = hmin;
  660. for(int i = 0; i <= TOP_INDEX; i++ ) {
  661. /*****************************************************************************/
  662. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  663. /*****************************************************************************/
  664. ihue = ihue + hinc;
  665. leds[i] = CHSV(ihue, thissat, 255);
  666. int ih = horizontal_index(i);
  667. leds[ih] = CHSV(ihue, thissat, 255);
  668. leds[TOP_INDEX].r = 255; leds[TOP_INDEX].g = 255; leds[TOP_INDEX].b = 255;
  669. LEDS.show();
  670. FastLED.delay(idelay);
  671. }
  672. /******************** END OF FUNCTION EFFECT *****************************/
  673. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  674. /******************** END OF FUNCTION EFFECT *****************************/
  675. }
  676.  
  677. void rainbow_vertical() { //-m23-RAINBOW 'UP' THE LOOP
  678. idex++;
  679.  
  680. if (idex > TOP_INDEX) {idex = 0;}
  681. ihue = ihue + thisstep;
  682. if (ihue > 255) {ihue = 0;}
  683. int idexA = idex;
  684. int idexB = horizontal_index(idexA);
  685. leds[idexA] = CHSV(ihue, thissat, 255);
  686. leds[idexB] = CHSV(ihue, thissat, 255);
  687. LEDS.show();
  688. FastLED.delay(thisdelay);
  689. /******************** END OF FUNCTION EFFECT *****************************/
  690. // buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  691. /******************** END OF FUNCTION EFFECT *****************************/
  692. }
  693.  
  694. void pacman() { //-m24-REALLY TERRIBLE PACMAN CHOMPING EFFECT
  695. int s = int(LED_COUNT/4);
  696. lcount++;
  697. /*****************************************************************************/
  698. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  699. /*****************************************************************************/
  700. if (lcount > 5) {lcount = 0;}
  701. if (lcount == 0) {
  702. for(int i = 0 ; i < LED_COUNT; i++ ) {set_color_led(i, 255, 255, 0);}
  703. }
  704. if (lcount == 1 || lcount == 5) {
  705. for(int i = 0 ; i < LED_COUNT; i++ ) {set_color_led(i, 255, 255, 0);}
  706. leds[s].r = 0; leds[s].g = 0; leds[s].b = 0;}
  707. if (lcount == 2 || lcount == 4) {
  708. for(int i = 0 ; i < LED_COUNT; i++ ) {set_color_led(i, 255, 255, 0);}
  709. leds[s-1].r = 0; leds[s-1].g = 0; leds[s-1].b = 0;
  710. leds[s].r = 0; leds[s].g = 0; leds[s].b = 0;
  711. leds[s+1].r = 0; leds[s+1].g = 0; leds[s+1].b = 0;}
  712. if (lcount == 3) {
  713. for(int i = 0 ; i < LED_COUNT; i++ ) {set_color_led(i, 255, 255, 0);}
  714. leds[s-2].r = 0; leds[s-2].g = 0; leds[s-2].b = 0;
  715. leds[s-1].r = 0; leds[s-1].g = 0; leds[s-1].b = 0;
  716. leds[s].r = 0; leds[s].g = 0; leds[s].b = 0;
  717. leds[s+1].r = 0; leds[s+1].g = 0; leds[s+1].b = 0;
  718. leds[s+2].r = 0; leds[s+2].g = 0; leds[s+2].b = 0;}
  719. LEDS.show();
  720. FastLED.delay(thisdelay);
  721. /******************** END OF FUNCTION EFFECT *****************************/
  722. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  723. /******************** END OF FUNCTION EFFECT *****************************/
  724. }
  725.  
  726. void random_color_pop() { //-m25-RANDOM COLOR POP
  727. idex = random(0, LED_COUNT);
  728. ihue = random(0, 255);
  729. one_color_all(0, 0, 0);
  730. /*****************************************************************************/
  731. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  732. /*****************************************************************************/
  733. leds[idex] = CHSV(ihue, thissat, 255);
  734. LEDS.show();
  735. FastLED.delay(thisdelay);
  736. /******************** END OF FUNCTION EFFECT *****************************/
  737. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  738. /******************** END OF FUNCTION EFFECT *****************************/
  739. }
  740.  
  741. void ems_lightsSTROBE() { //-m26-EMERGENCY LIGHTS (STROBE LEFT/RIGHT)
  742. int thishue = 0;
  743. int thathue = (thishue + 160) % 255;
  744. for(int x = 0 ; x < 5; x++ ) {
  745. for(int i = 0 ; i < TOP_INDEX; i++ ) {
  746. /*****************************************************************************/
  747. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  748. /*****************************************************************************/
  749. leds[i] = CHSV(thishue, thissat, 255);
  750. }
  751. LEDS.show(); FastLED.delay(thisdelay);
  752. one_color_all(0, 0, 0);
  753. LEDS.show(); FastLED.delay(thisdelay);
  754. }
  755. for(int x = 0 ; x < 5; x++ ) {
  756. /*****************************************************************************/
  757. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  758. /*****************************************************************************/
  759. for(int i = TOP_INDEX ; i < LED_COUNT; i++ ) {
  760. leds[i] = CHSV(thathue, thissat, 255);
  761. }
  762. LEDS.show(); FastLED.delay(thisdelay);
  763. one_color_all(0, 0, 0);
  764. LEDS.show(); FastLED.delay(thisdelay);
  765. }
  766. /******************** END OF FUNCTION EFFECT *****************************/
  767. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  768. /******************** END OF FUNCTION EFFECT *****************************/
  769. }
  770.  
  771. void rgb_propeller() { //-m27-RGB PROPELLER
  772. idex++;
  773. int ghue = (thishue + 80) % 255;
  774. int bhue = (thishue + 160) % 255;
  775. int N3 = int(LED_COUNT/3);
  776. int N6 = int(LED_COUNT/6);
  777. int N12 = int(LED_COUNT/12);
  778. for(int i = 0; i < N3; i++ ) {
  779. /*****************************************************************************/
  780. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  781. /*****************************************************************************/
  782. int j0 = (idex + i + LED_COUNT - N12) % LED_COUNT;
  783. int j1 = (j0+N3) % LED_COUNT;
  784. int j2 = (j1+N3) % LED_COUNT;
  785. leds[j0] = CHSV(thishue, thissat, 255);
  786. leds[j1] = CHSV(ghue, thissat, 255);
  787. leds[j2] = CHSV(bhue, thissat, 255);
  788. }
  789. /*****************************************************************************/
  790. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  791. /*****************************************************************************/
  792. LEDS.show();
  793. FastLED.delay(thisdelay);
  794. /******************** END OF FUNCTION EFFECT *****************************/
  795. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  796. /******************** END OF FUNCTION EFFECT *****************************/
  797. }
  798.  
  799. void kitt() { //-m28-KNIGHT INDUSTIES 2000
  800. int rand = random(0, TOP_INDEX);
  801. for(int i = 0; i < rand; i++ ) {
  802. /*****************************************************************************/
  803. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  804. /*****************************************************************************/
  805. leds[TOP_INDEX+i] = CHSV(thishue, thissat, 255);
  806. leds[TOP_INDEX-i] = CHSV(thishue, thissat, 255);
  807. LEDS.show();
  808. FastLED.delay(thisdelay/rand);
  809. }
  810. for(int i = rand; i > 0; i-- ) {
  811. /*****************************************************************************/
  812. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  813. /*****************************************************************************/
  814. leds[TOP_INDEX+i] = CHSV(thishue, thissat, 0);
  815. leds[TOP_INDEX-i] = CHSV(thishue, thissat, 0);
  816. LEDS.show();
  817. FastLED.delay(thisdelay/rand);
  818. }
  819. /******************** END OF FUNCTION EFFECT *****************************/
  820. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  821. /******************** END OF FUNCTION EFFECT *****************************/
  822. }
  823.  
  824. void matrix() { //-m29-ONE LINE MATRIX
  825. int rand = random(0, 75);
  826. if (rand > 90) {
  827. leds[0] = CHSV(thishue, thissat, 255);
  828. }
  829. else {leds[0] = CHSV(thishue, thissat, 0);}
  830. copy_led_array();
  831. for(int i = 1; i < LED_COUNT; i++ ) {
  832. /*****************************************************************************/
  833. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  834. /*****************************************************************************/
  835. leds[i].r = ledsX[i-1][0];
  836. leds[i].g = ledsX[i-1][1];
  837. leds[i].b = ledsX[i-1][2];
  838. }
  839. LEDS.show();
  840. FastLED.delay(thisdelay);
  841. /******************** END OF FUNCTION EFFECT *****************************/
  842. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  843. /******************** END OF FUNCTION EFFECT *****************************/
  844. }
  845.  
  846. void strip_march_cw() { //-m50-MARCH STRIP CW
  847. copy_led_array();
  848. int iCW;
  849. for(int i = 0; i < LED_COUNT; i++ ) {
  850. /*****************************************************************************/
  851. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  852. /*****************************************************************************/
  853. iCW = adjacent_cw(i);
  854. leds[i].r = ledsX[iCW][0];
  855. leds[i].g = ledsX[iCW][1];
  856. leds[i].b = ledsX[iCW][2];
  857. }
  858. LEDS.show();
  859. FastLED.delay(thisdelay);
  860. /******************** END OF FUNCTION EFFECT *****************************/
  861. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  862. /******************** END OF FUNCTION EFFECT *****************************/
  863. }
  864.  
  865. void strip_march_ccw() { //-m51-MARCH STRIP CCW
  866. copy_led_array();
  867. int iCCW;
  868. for(int i = 0; i < LED_COUNT; i++ ) {
  869. /*****************************************************************************/
  870. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  871. /*****************************************************************************/
  872. iCCW = adjacent_ccw(i);
  873. leds[i].r = ledsX[iCCW][0];
  874. leds[i].g = ledsX[iCCW][1];
  875. leds[i].b = ledsX[iCCW][2];
  876. }
  877. LEDS.show();
  878. FastLED.delay(thisdelay);
  879. /******************** END OF FUNCTION EFFECT *****************************/
  880. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  881. /******************** END OF FUNCTION EFFECT *****************************/
  882. }
  883.  
  884. void new_rainbow_loop(){ //-m88-RAINBOW FADE FROM FAST_SPI2
  885. ihue -= 1;
  886. fill_rainbow( leds, LED_COUNT, ihue );
  887. /*****************************************************************************/
  888. if(buttonstate){Serial.println("BUTTON PRESSED");buttonstate=0;goto buttonPress;}
  889. /*****************************************************************************/
  890. LEDS.show();
  891. FastLED.delay(thisdelay);
  892. /******************** END OF FUNCTION EFFECT *****************************/
  893. buttonPress: Serial.println("End of effect. Mode is now:");Serial.println(ledMode);return; // End Effect
  894. /******************** END OF FUNCTION EFFECT *****************************/
  895. }
  896.  
  897. void demo_modeA(){
  898. int r = 15;
  899. thisdelay = 20; thisstep = 10; thishue = 0; thissat = 255;
  900. //one_color_all(255,255,255); LEDS.show(); FastLED.delay(1200);
  901. for(int i=0; i<r*35; i++) {if(buttonstate){}; thisdelay = 40; rainbow_fade();}
  902. for(int i=0; i<r*30; i++) {if(buttonstate){};rainbow_loop();}
  903. for(int i=0; i<r*40; i++) {if(buttonstate){};random_burst();}
  904. for(int i=0; i<r*42; i++) {if(buttonstate){};color_bounce();}
  905. thisdelay = 40;
  906. for(int i=0; i<r*42; i++) {if(buttonstate){};color_bounceFADE();}
  907. for(int i=0; i<r*12; i++) {if(buttonstate){};ems_lightsONE();}
  908. for(int i=0; i<r*10; i++) {if(buttonstate){};ems_lightsALL();}
  909. thishue = 160; thissat = 50;
  910. for(int i=0; i<r*40; i++) {if(buttonstate){};flicker();}
  911. one_color_all(0,0,0); LEDS.show();
  912. thisdelay = 15; thishue = 0; thissat = 255;
  913. for(int i=0; i<r*50; i++) {if(buttonstate){};pulse_one_color_all();}
  914. for(int i=0; i<r*40; i++) {if(buttonstate){};pulse_one_color_all_rev();}
  915. thisdelay = 60; thishue = 180;
  916. for(int i=0; i<r*5; i++) {if(buttonstate){};fade_vertical();}
  917. random_red();
  918. thisdelay = 100;
  919. for(int i=0; i<r*5; i++) {if(buttonstate){};rule30();}
  920. thisdelay = 40;
  921. for(int i=0; i<r*8; i++) {if(buttonstate){};random_march();}
  922. thisdelay = 80;
  923. for(int i=0; i<r*5; i++) {if(buttonstate){};rwb_march();}
  924. one_color_all(0,0,0); ; LEDS.show();
  925. thisdelay = 60; thishue = 95;
  926. for(int i=0; i<r*15; i++) {if(buttonstate){};radiation();}
  927. for(int i=0; i<r*15; i++) {if(buttonstate){};color_loop_vardelay();}
  928. //for(int i=0; i<r*5; i++) {if(buttonstate){};white_temps();}
  929. thisdelay = 35; thishue = 180;
  930. for(int i=0; i<r; i++) {if(buttonstate){};sin_bright_wave();}
  931. thisdelay = 100; thishue = 100;
  932. for(int i=0; i<r*5; i++) {if(buttonstate){};pop_horizontal();}
  933. thisdelay = 100; thishue = 180;
  934. for(int i=0; i<r*4; i++) {if(buttonstate){};quad_bright_curve();}
  935. one_color_all(0,0,0); LEDS.show();
  936. for(int i=0; i<r*3; i++) {if(buttonstate){};flame();}
  937. thisdelay = 100; thishue = 175;
  938. for(int i=0; i<r*5; i++) {if(buttonstate){};pop_horizontal();}
  939. thisdelay = 50;
  940. for(int i=0; i<r*10; i++) {if(buttonstate){};pacman();}
  941. thisdelay = 50; thisstep = 15;
  942. for(int i=0; i<r*12; i++) {if(buttonstate){};rainbow_vertical();}
  943. thisdelay = 100;
  944. for(int i=0; i<r*3; i++) {if(buttonstate){};strip_march_ccw();}
  945. for(int i=0; i<r*3; i++) {if(buttonstate){};strip_march_cw();}
  946. demo_modeB();
  947. thisdelay = 5;
  948. for(int i=0; i<r*120; i++) {if(buttonstate){};new_rainbow_loop();}
  949. one_color_all(255,0,0); LEDS.show(); FastLED.delay(1200);
  950. one_color_all(0,255,0); LEDS.show(); FastLED.delay(1200);
  951. one_color_all(0,0,255); LEDS.show(); FastLED.delay(1200);
  952. one_color_all(255,255,0); LEDS.show(); FastLED.delay(1200);
  953. one_color_all(0,255,255); LEDS.show(); FastLED.delay(1200);
  954. one_color_all(255,0,255); LEDS.show(); FastLED.delay(1200);
  955. }
  956.  
  957. void demo_modeB(){
  958. int r = 10;
  959. one_color_all(0,0,0); LEDS.show();
  960. thisdelay = 35;
  961. for(int i=0; i<r*10; i++) {random_color_pop();}
  962. for(int i=0; i<r/2; i++) {ems_lightsSTROBE();}
  963. thisdelay = 50;
  964. for(int i=0; i<r*10; i++) {rgb_propeller();}
  965. one_color_all(0,0,0); LEDS.show();
  966. thisdelay = 100; thishue = 0;
  967. for(int i=0; i<r*3; i++) {kitt();}
  968. one_color_all(0,0,0); LEDS.show();
  969. thisdelay = 30; thishue = 95;
  970. for(int i=0; i<r*25; i++) {matrix();}
  971. one_color_all(0,0,0); LEDS.show();
  972. }
  973.  
  974. void change_mode(int newmode){
  975. thissat = 255;
  976. switch (newmode) {
  977. case 0: one_color_all(0,0,0); LEDS.show(); break; //---ALL OFF
  978. case 1: one_color_all(255,255,255); LEDS.show(); break; //---ALL ON
  979. case 2: thisdelay = 20; break; //---STRIP RAINBOW FADE
  980. case 3: thisdelay = 0; thisstep = 50; break; //---RAINBOW LOOP
  981. case 4: thisdelay = 20; break; //---RANDOM BURST
  982. case 5: thisdelay = 20; thishue = 0; // random(0,250); break; //---CYLON v1
  983. case 6: thisdelay = 40; thishue = random(0,250); break; //---CYLON v2
  984. case 7: thisdelay = 40; thishue = random(0,250); break; //---POLICE LIGHTS SINGLE
  985. case 8: thisdelay = 40; thishue = random(0,250); break; //---POLICE LIGHTS SOLID
  986. case 9: thishue = 160; thishue = random(0,250); break; //---STRIP FLICKER
  987. case 10: thisdelay = 10; thishue = random(0,250); break; //---PULSE COLOR BRIGHTNESS
  988. case 11: thisdelay = 10; thishue = random(0,250); break; //---PULSE COLOR SATURATION
  989. case 12: thisdelay = 60; thishue = random(0,250); break; //---VERTICAL SOMETHING
  990. case 13: thisdelay = 100;thishue = random(0,250); break; //---CELL AUTO - RULE 30 (RED)
  991. case 14: thisdelay = 70; thishue = random(0,250); break; //---MARCH RANDOM COLORS
  992. case 15: thisdelay = 100; thishue = random(0,250); break; //---MARCH RWB COLORS
  993. case 16: thisdelay = 0; thishue = random(0,250); break; //---RADIATION SYMBOL
  994. case 17: thisdelay = 60; thishue = random(0,250); break;
  995. case 18: thisdelay = 10; thishue = random(0,250);break;
  996. case 19: thisdelay = 35; thishue = random(0,250); break; //---SIN WAVE BRIGHTNESS
  997. case 20: thisdelay = 100; thishue = random(0,250); break; //---POP LEFT/RIGHT
  998. case 21: thisdelay = 100; thishue = random(0,250); break; //---QUADRATIC BRIGHTNESS CURVE
  999. case 22: thisdelay = 60; thishue = random(0,250); break;
  1000. case 23: thisdelay = 50; thisstep = 15; thishue = random(0,250); break; //---VERITCAL RAINBOW
  1001. case 24: thisdelay = 70; thishue = random(0,250); break; //---PACMAN
  1002. case 25: thisdelay = 45; thishue = random(0,250); break; //---RANDOM COLOR POP
  1003. case 26: thisdelay = 125; thishue = random(0,250); break; //---EMERGECNY STROBE
  1004. case 27: thisdelay = 25; thishue = random(0,250); break; //---RGB PROPELLER
  1005. case 28: thisdelay = 100; thishue = random(0,250); break; //---KITT
  1006. case 29: thisdelay = 50; thishue = random(0,250); break; //---MATRIX RAIN
  1007. case 50: thisdelay = 100; break; //---MARCH STRIP NOW CCW
  1008. case 51: thisdelay = 100; break; //---MARCH STRIP NOW CCW
  1009. case 88: thisdelay = 5; break; //---NEW RAINBOW LOOP
  1010. case 101: one_color_all(255,0,0); LEDS.show(); break; //---ALL RED
  1011. case 102: one_color_all(0,255,0); LEDS.show(); break; //---ALL GREEN
  1012. case 103: one_color_all(0,0,255); LEDS.show(); break; //---ALL BLUE
  1013. case 104: one_color_all(255,255,0); LEDS.show(); break; //---ALL COLOR X
  1014. case 105: one_color_all(0,255,255); LEDS.show(); break; //---ALL COLOR Y
  1015. case 106: one_color_all(255,0,255); LEDS.show(); break; //---ALL COLOR Z
  1016. }
  1017. bouncedirection = 0;
  1018. one_color_all(0,0,0);
  1019. ledMode = newmode;
  1020. }
  1021.  
  1022.  
  1023. //------------------SETUP------------------
  1024. void setup()
  1025. {
  1026. Serial.begin(SERIAL_BAUDRATE); // SETUP HARDWARE SERIAL (USB)
  1027. pinMode(pbIn, INPUT);
  1028. attachInterrupt(pbIn, stateChange, CHANGE);
  1029. LEDS.setBrightness(max_bright);
  1030.  
  1031. //////////////////////////
  1032. // FASTLEDS
  1033. //////////////////////////
  1034.  
  1035.  
  1036. time.every(45000, timer);
  1037.  
  1038.  
  1039.  
  1040. //FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
  1041. FastLED.addLeds<WS2812B, 2, GRB>(leds, NUM_LEDS);
  1042. one_color_all(0,0,0); //-CLEAR STRIP
  1043. LEDS.show();
  1044. Serial.println("---SETUP COMPLETE---");
  1045. }
  1046.  
  1047.  
  1048. //------------------MAIN LOOP------------------
  1049. void loop() {
  1050. time.update();
  1051. switch (ledMode) {
  1052. case 999: break;
  1053. case 2: rainbow_fade(); break;
  1054. //case 2: ColorForest(); break; //for testing
  1055. case 3: rainbow_loop(); break;
  1056. case 4: ColorOcean(); break;
  1057. case 5: ColorRandom(); break;
  1058. case 6: color_bounceFADE(); break;
  1059. case 7: ColorPalette(); break;
  1060. case 8: ColorBW(); break;
  1061. case 9: color_bounceFADE(); break;
  1062. case 10: pulse_one_color_all(); break;
  1063. case 11: ColorForest(); break;
  1064. case 12: fade_vertical(); break;
  1065. case 13: ColorForest(); break;
  1066. case 14: random_color_pop(); break;
  1067. case 15: ColorPalette(); break;
  1068. case 16: rainbow_loop(); break;
  1069. case 17: kitt(); break;
  1070. case 18: pulse_one_color_all(); break;
  1071. case 19: ColorRandom(); break;
  1072. case 20: pop_horizontal(); break;
  1073. case 21: ColorPG();break;
  1074. case 22: color_loop_vardelay(); break;
  1075. case 23: rainbow_vertical(); break;
  1076. case 24: pop_horizontal(); break;
  1077. case 25: random_color_pop(); break;
  1078. case 26: ems_lightsSTROBE(); break;
  1079. case 27: ColorLava(); break;
  1080. case 28: kitt(); break;
  1081. case 29: color_loop_vardelay();break;
  1082. case 50: strip_march_ccw(); break;
  1083. case 51: strip_march_cw(); break;
  1084. case 88: new_rainbow_loop(); break;
  1085. case 888: demo_modeA(); break;
  1086. case 889: demo_modeB(); break;
  1087. }
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095. ///////////////////////// SERIAL AND BLUETOOTH STUFF
  1096. /*
  1097. //---PROCESS HARDWARE SERIAL COMMANDS AND ARGS
  1098. while (Serial.available() > 0) {
  1099. Serial.println("HARDWARE AVAILABLE");
  1100. inbyte = Serial.read();
  1101. Serial.println(inbyte);
  1102. switch(inbyte) {
  1103. case 59: break; //---BREAK IF INBYTE = ';'
  1104. case 108: //---"l" - SET SINGLE LED VALUE RGB
  1105. thisindex = Serial.parseInt();
  1106. thisRED = Serial.parseInt();
  1107. thisGRN = Serial.parseInt();
  1108. thisBLU = Serial.parseInt();
  1109. if (ledMode != 999) {
  1110. ledMode = 999;
  1111. one_color_all(0,0,0);}
  1112. leds[thisindex].setRGB( thisRED, thisGRN, thisBLU);
  1113. break;
  1114. case 118: //---"v" - SET SINGLE LED VALUE HSV
  1115. thisindex = Serial.parseInt();
  1116. thishue = Serial.parseInt();
  1117. thissat = Serial.parseInt();
  1118. //thisVAL = Serial.parseInt();
  1119. if (ledMode != 999) {
  1120. ledMode = 999;
  1121. one_color_all(0,0,0);}
  1122. leds[thisindex] = CHSV(thishue, thissat, 255);
  1123. break;
  1124. case 100: //---"d" - SET DELAY VAR
  1125. thisarg = Serial.parseInt();
  1126. thisdelay = thisarg;
  1127. break;
  1128. case 115: //---"s" - SET STEP VAR
  1129. thisarg = Serial.parseInt();
  1130. thisstep = thisarg;
  1131. break;
  1132. case 104: //---"h" - SET HUE VAR
  1133. thisarg = Serial.parseInt();
  1134. thishue = thisarg;
  1135. break;
  1136. case 116: //---"t" - SET SATURATION VAR
  1137. thisarg = Serial.parseInt();
  1138. thissat = thisarg;
  1139. break;
  1140. case 98: //---"b" - SET MAX BRIGHTNESS
  1141. max_bright = Serial.parseInt();
  1142. LEDS.setBrightness(max_bright);
  1143. break;
  1144. case 109: //---"m" - SET MODE
  1145. thisarg = Serial.parseInt();
  1146. Serial.println(thisarg);
  1147. Serial.println("TEST MODE");
  1148. change_mode(thisarg);
  1149. break;
  1150. case 99: //---"c" - CLEAR STRIP
  1151. one_color_all(0,0,0);
  1152. break;
  1153. case 97: //---"a" - SET ALL TO ONE COLOR BY HSV 0-255
  1154. thisarg = Serial.parseInt();
  1155. one_color_allHSV(thisarg);
  1156. break;
  1157. case 122: //---"z" - COMMAND TO 'SHOW' LEDS
  1158. LEDS.show();
  1159. break;
  1160. case 81: //---"Q" - COMMAND RETURN VERSION NUMBER
  1161. Serial.print(VERSION_NUMBER);
  1162. break;
  1163. }
  1164. }
  1165. */
  1166.  
  1167. /*
  1168. //---PROCESS SOFTWARE SERIAL COMMANDS AND ARGS
  1169. while (btSerial.available() > 0) {
  1170. //Serial.println("BT AVAILABLE");
  1171. inbyteB = btSerial.read();
  1172. Serial.println(inbyteB);
  1173. if (btSerial.overflow()){Serial.println("SoftwareSerial overflow!");}
  1174. switch(inbyteB) {
  1175. case 59: break; //---BREAK IF INBYTE = ';'
  1176. case 108: //---"l" - SET SINGLE LED VALUE
  1177. thisindex = btSerial.parseInt();
  1178. thisRED = btSerial.parseInt();
  1179. thisGRN = btSerial.parseInt();
  1180. thisBLU = btSerial.parseInt();
  1181. if (ledMode != 999) {
  1182. ledMode = 999;
  1183. one_color_all(0,0,0);}
  1184. leds[thisindex].setRGB( thisRED, thisGRN, thisBLU);
  1185. break;
  1186. case 100: //---"d" - SET DELAY VAR
  1187. thisarg = btSerial.parseInt();
  1188. thisdelay = thisarg;
  1189. Serial.println(thisdelay);
  1190. break;
  1191. case 115: //---"s" - SET STEP VAR
  1192. thisarg = btSerial.parseInt();
  1193. thisstep = thisarg;
  1194. break;
  1195. case 104: //---"h" - SET HUE VAR
  1196. thisarg = btSerial.parseInt();
  1197. thishue = thisarg;
  1198. break;
  1199. case 116: //---"t" - SET SATURATION VAR
  1200. thisarg = btSerial.parseInt();
  1201. thissat = thisarg;
  1202. Serial.println(thisarg);
  1203. break;
  1204. case 98: //---"b" - SET MAX BRIGHTNESS
  1205. max_bright = btSerial.parseInt();
  1206. Serial.println(max_bright);
  1207. LEDS.setBrightness(max_bright);
  1208. break;
  1209. case 109: //---"m" - SET MODE
  1210. thisarg = btSerial.parseInt();
  1211. Serial.println("M COMMAND");
  1212. Serial.println(thisarg);
  1213. change_mode(thisarg);
  1214. break;
  1215. case 99: //---"c" - CLEAR STRIP
  1216. one_color_all(0,0,0);
  1217. break;
  1218. case 97: //---"a" - SET ALL TO ONE COLOR BY HSV 0-255
  1219. thisarg = btSerial.parseInt();
  1220. one_color_allHSV(thisarg);
  1221. break;
  1222. case 122: //---"z" - COMMAND TO 'SHOW' LEDS
  1223. LEDS.show();
  1224. //Serial.println("Z COMMAND");
  1225. break;
  1226. }
  1227. }
  1228. */
  1229.  
  1230. //FastLED.delay(110);
  1231. }
  1232.  
  1233.  
  1234. void stateChange()
  1235. {
  1236. //Serial.println("Button Pressed");
  1237. //delay(10);
  1238. buttonstate = 1;
  1239. ledMode++;
  1240.  
  1241. //if (ledMode > 29) {ledMode=1;};
  1242. //Serial.println("ledMode"); Serial.println(ledMode);
  1243. }
  1244.  
  1245.  
  1246. ////////////////// AUTO TIMER /////////////////////////////////////
  1247. void timer()
  1248. {
  1249. Serial.println("TIMER ledMode is now:");Serial.println(newmode);
  1250. newmode++;
  1251. Serial.println(" NewMode is now:");Serial.println(newmode);
  1252. if (newmode > 29) { newmode = 2; }
  1253. change_mode(newmode);
  1254. }
  1255. ///////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment