Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <Servo.h>
  2.  
  3.  
  4. Servo myservo; // create servo object to control a servo
  5. // twelve servo objects can be created on most boards
  6.  
  7. int pos = 0; // variable to store the servo position
  8.  
  9. void setup() {
  10. myservo.attach(9); // attaches the servo on pin 9 to the servo object
  11. Serial.begin(9600);
  12.  
  13. }
  14.  
  15. int i = 0;
  16.  
  17. void loop() {
  18. if(Serial.available()) {
  19. i = Serial.parseInt();
  20. }
  21. Serial.println(i);
  22. myservo.writeMicroseconds(i);
  23. delay(50);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement