Created
February 18, 2018 04:30
-
-
Save nasustim/f507cc329c972d620a625a9c4c978d3a to your computer and use it in GitHub Desktop.
Arduino_UnlimitedRotateServo
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> | |
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