Guest User

Arduino conexión servomotor

a guest
Apr 21st, 2010
1,363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1.  
  2. #include "Servo.h"
  3.  
  4. Servo myservo;  //objeto a controlar, un servo  
  5.  
  6. int pos = 0;   // variable de posición de partida del servo
  7.  
  8. void setup() {
  9.     myservo.attach(9); //pin de conexión servo, control
  10. }
  11.  
  12. void loop() {
  13.     for(pos = 0; pos < 180; pos += 1);  //posición inicial y posición final
  14.     {
  15.       myservo.write(pos);
  16.       delay(1000);
  17.     }
  18.     for(pos = 180; pos>=1; pos-=1);
  19.     {
  20.       myservo.write(pos);
  21.       delay(1000 );
  22.     }    
  23. }
Advertisement
Add Comment
Please, Sign In to add comment