Skip to content

Instantly share code, notes, and snippets.

@TakesTheBiscuit
Created August 21, 2018 21:14
Show Gist options
  • Save TakesTheBiscuit/a76c9a21afb53cc327745e4a7a30f2ff to your computer and use it in GitHub Desktop.
Save TakesTheBiscuit/a76c9a21afb53cc327745e4a7a30f2ff to your computer and use it in GitHub Desktop.
continuous rotation servo clock and anticlock
// TURN CLOCKWISE, WAIT A BIT, THEN GO ANTI CLOCK DEMO ONLY
#include <Servo.h>
#define TURN_TIME 1200
Servo myservo;
void setup() {
myservo.attach(9);
// Initially the servo must be stopped
}
void loop() {
// Start turning clockwise
myservo.write(0);
delay(TURN_TIME);
delay(TURN_TIME);
// go back other way
myservo.write(180);
// Wait for 1200ms
delay(TURN_TIME);
delay(TURN_TIME);
// kills the pwm signal
myservo.detach();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment