Created
July 29, 2015 21:53
-
-
Save mithi/4f12310356e7b0a1bb12 to your computer and use it in GitHub Desktop.
crazy sun snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void stopSignal(){ | |
for (int x = 1; x < 10; x++){ | |
sparki.beep(); | |
sparki.RGB(50, 0, 100); | |
delay(200); | |
} | |
sparki.RGB(RGB_OFF); | |
} | |
void stopMotors(){ | |
sparki.motorStop(MOTOR_LEFT); | |
sparki.motorStop(MOTOR_RIGHT); | |
stopSignal(); | |
} | |
void forwardWheels(int leftSpeed, int rightSpeed, int waitmSec) { | |
turnSignal(); | |
sparki.motorRotate(MOTOR_LEFT, DIR_CCW, leftSpeed); | |
sparki.motorRotate(MOTOR_RIGHT, DIR_CW, rightSpeed); | |
delay(waitmSec); | |
} | |
void reverseWheels(int leftSpeed, int rightSpeed, int waitmSec) { | |
turnSignal(); | |
sparki.motorRotate(MOTOR_LEFT, DIR_CW, leftSpeed); | |
sparki.motorRotate(MOTOR_RIGHT, DIR_CCW, rightSpeed); | |
delay(waitmSec); | |
} | |
void crazySun(int speed1, int speed2, int waitmSec, unsigned long timeToDo){ | |
unsigned long endTime = millis() + timeToDo; | |
while(millis() < endTime){ | |
forwardWheels(speed1, speed2, waitmSec); | |
reverseWheels(speed2, speed1, waitmSec); | |
} | |
stopMotors(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment