Skip to content

Instantly share code, notes, and snippets.

@lvidarte
Created December 25, 2014 22:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lvidarte/e18d30d32fc95d4ba12f to your computer and use it in GitHub Desktop.
Save lvidarte/e18d30d32fc95d4ba12f to your computer and use it in GitHub Desktop.
Servo DS04-NFC 360° Continuous Rotation
#include <Servo.h>
#define SERVO_PIN 9
#define CW 1900
#define STOP 1450
#define CCW 1000
Servo myServo;
char c;
void setup()
{
Serial.begin(57600);
myServo.attach(SERVO_PIN);
myServo.writeMicroseconds(STOP);
}
void loop()
{
while (Serial.available() > 0) {
c = Serial.read();
switch (c) {
case 'c':
myServo.writeMicroseconds(CW);
break;
case 'w':
myServo.writeMicroseconds(CCW);
break;
case 's':
myServo.writeMicroseconds(STOP);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment