Guest User

Untitled

a guest
Feb 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #define servoPin 12
  2.  
  3. void setup() {
  4. Serial.begin(115200);
  5. pinMode(servoPin, OUTPUT);
  6. }
  7.  
  8. void loop() {
  9. for (float pos = -90; pos <= 90; pos += 0.1) {
  10. float msec = pos / 90.0 * 0.5 + 1.5;
  11. long limitUSec = msec * 1000;
  12.  
  13. digitalWrite(servoPin, HIGH);
  14. delayMicroseconds(limitUSec);
  15. digitalWrite(servoPin, LOW);
  16. delayMicroseconds(10000-limitUSec);
  17.  
  18. delay(10);
  19. }
  20. delay(1000);
  21. }
Add Comment
Please, Sign In to add comment