Created
November 17, 2013 00:44
-
-
Save 4m1g0/7507480 to your computer and use it in GitHub Desktop.
Código arduino para probar servos de rotación continua. El servo debe comenzar a girar en un sentido cada vez mas rapido, posteriormente pararse y hacer lo mismo en el sentido contrario.
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
// Prueba de servos giro continuo | |
// bricolabs.cc | |
// Este codigo es de uso libre | |
#include <Servo.h> | |
Servo myservo; // Cremos el objeto de servo | |
const int speed0 = 90; // valor en el que el servo se mantiene quieto (es posible que haga falta variarlo un poco) | |
int i; // iterador | |
void setup() | |
{ | |
myservo.attach(8); // attaches the servo on pin 9 to the servo object | |
} | |
void loop() | |
{ | |
for(i = 0; i < 90; i++) // vamos desde velocidad 0 hasta velocidad 90 (maximo) | |
{ | |
myservo.write(speed0 + i); | |
delay(15); | |
} | |
myservo.write(speed0); | |
delay(1000); | |
// sentido contrario | |
for(int i = 0; i < 90; i++) // vamos desde velocidad 0 hasta velocidad 90 (maximo) | |
{ | |
myservo.write(speed0 - i); | |
delay(15); | |
} | |
myservo.write(speed0); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment