/******************************** CHASE THE DOT *******************************\ | A single point of light moves around the cube randomly and changes colors | | when it tries to go out of bounds | | | | Inspired By: Jonah Glick | | Written By: Asher Glick | \******************************************************************************/ int xpos = 0; int ypos = 0; int zpos = 0; int animationSpeed = 100; void chaseTheDot() { //continuePattern = true; if (currentState != lastState) { lastState = currentState; Serial.print("last State = "); Serial.println(lastState); xpos = 0; ypos = 0; zpos = 0; } //while (continuePattern) { if ( not animationDelayTiming) { switch (random(0, 6)) { case 0: if (xpos > 0) { xpos--; break; } else color = nextColor(color); case 1: if (xpos < 3) { xpos++; break; } else color = nextColor(color); xpos--; break; case 2: if (ypos > 0) { ypos--; break; } else color = nextColor(color); case 3: if (ypos < 3) { ypos++; break; } else color = nextColor(color); ypos--; break; case 4: if (zpos > 0) { zpos--; break; } else color = nextColor(color); case 5: if (zpos < 3) { zpos++; break; } else color = nextColor(color); zpos--; break; } drawLed(color, xpos, ypos, zpos); flushBuffer(); clearBuffer(); //delay(animationSpeed); animationDelay.start(); animationDelayTiming = true; Serial.println("start timer"); } }