/********************************** FOUNTIAN **********************************\ | Light shoots up the middle of the cube then once it reaches the top fall | | back down on the outside of the cube. After it hits the bottom it changes | | color and starts again | | | | Written By: Asher Glick | | Modified By: S. Dugre to use asynchronous timer | \******************************************************************************/ int fountain_loop; void fountain() { if (currentState != lastState) { lastState = currentState; Serial.print("New State = "); Serial.println(currentState); currentTimer = 0; maxTimer = 0.2 * 1000 * 1000 / 16; // 0.1 seconds fountain_loop = 0; } if ( timerReset) { switch (fountain_loop){ case 0 ... 3: //for (int z = 0; z <= 3; z++) { drawBoxWalls(color,1,1,fountain_loop,2,2,fountain_loop); flushBuffer(); clearBuffer(); fountain_loop++; timerReset = false; break; case 4 ... 7: //for (int z = 3; z >= 0; z--) { drawBoxWalls(color,0,0,7-fountain_loop,3,3,7-fountain_loop); flushBuffer(); clearBuffer(); if(fountain_loop >= 7){ fountain_loop = 0; color = nextColor(color); } else fountain_loop++; timerReset = false; break; } } }