Skip to content

Instantly share code, notes, and snippets.

@nasustim
Created February 18, 2018 04:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nasustim/f507cc329c972d620a625a9c4c978d3a to your computer and use it in GitHub Desktop.
Save nasustim/f507cc329c972d620a625a9c4c978d3a to your computer and use it in GitHub Desktop.
Arduino_UnlimitedRotateServo
#include<Servo.h>
Servo s;
void setup(){
s.attach(13);
}
void loop(){
turn(180);
turn(-180);
}
void turn(int deg){
int _speed = (deg<0)?1000:2000;
float angle = 800 / 90 * abs(deg);
s.writeMicroseconds(_speed);
delay(int(angle));
s.writeMicroseconds(1500);
delay(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment