int servoPin = D1;
int servoPosition = 0;
Servo servo;
bool shouldWobble = false;
bool shouldCountdown = false;
void setup() {
servo.attach(servoPin);
servo.write(0);
delay(500);
servo.write(180);
delay(500);
servo.write(90);
delay(500);
Particle.function("wobble", handleWobble);
Particle.function("counter", handleCounterStart);
}
int handleWobble(String cmd) {
shouldWobble = true;
return 1;
}
int handleCounterStart(String cmd) {
shouldCountdown = true;
return 1;
}
void loop() {
if (shouldWobble) {
for (int i = 0; i < 10; i++) {
servo.write(70);
delay(100);
servo.write(110);
delay(100);
}
shouldWobble = false;
}
if (shouldCountdown) {
for (int i = 180; i >= 0; i -= 5) {
servo.write(i);
delay(250);
}
shouldCountdown = false;
}
delay(1000);
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .