Created
December 25, 2014 22:57
-
-
Save lvidarte/e18d30d32fc95d4ba12f to your computer and use it in GitHub Desktop.
Servo DS04-NFC 360° Continuous Rotation
This file contains 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
#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