Created
February 9, 2018 23:32
-
-
Save TareObjects/12106bf52ba1bc9176805749ab9f3943 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#define servoPin 12 | |
void setup() { | |
Serial.begin(115200); | |
pinMode(servoPin, OUTPUT); | |
} | |
void loop() { | |
for (float pos = -90; pos <= 90; pos += 0.1) { | |
float msec = pos / 90.0 * 0.5 + 1.5; | |
long limitUSec = msec * 1000; | |
digitalWrite(servoPin, HIGH); | |
delayMicroseconds(limitUSec); | |
digitalWrite(servoPin, LOW); | |
delayMicroseconds(10000-limitUSec); | |
delay(10); | |
} | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment