Hide minor edits - Show changes to markup
Examples > Servo Library
Sweeps the shaft of a servo motor back and forth.
Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow, orange or white and should be connected to pin 9 on the Arduino board.
Ejemplo > Librería Servo
Mueve el eje del servo motor de un lado al otro.
Los servo motores poseen tres terminales: alimentación, masa y señal. El terminal de alimentación, es normalmente rojo,y se debe conectar al pin 5V de la placa Arduino. El terminal de masa el cual es normalmente negro debe de conectarse a el pin de masa del la placa Arduino. El cable de señal suele ser amarillo, naranja o blanco y debe conectarse al pin 9 de la placa Arduino.
// by BARRAGAN <http://barraganstudio.com>
// por BARRAGAN <http://barraganstudio.com>
Servo myservo; // create servo object to control a servo
int pos = 0; // variable to store the servo position
Servo myservo; // crea un objeto tipo servo para controlar el servo
int pos = 0; // variable para almacenar la posición del servo
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo.attach(9); // liga el servo conectado en el pin 9 al objeto servo
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
for(pos = 0; pos < 180; pos += 1) // va de 0 a 180 grados
{ // en pasos de 1 grado
myservo.write(pos); // dice al servo que se posicione en la posición indicada por la variable 'pos'
delay(15); // espera 15 ms para dar tiempo al servo a llegar a la nueva posición
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
for(pos = 180; pos>=1; pos-=1) // va de 180 a 0 grados
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
myservo.write(pos); // dice al servo que se posicione en la posición indicada por la variable 'pos'
delay(15); // espera 15 ms para dar tiempo al servo a llegar a la nueva posición
Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow or orange and should be connected to pin 9 on the Arduino board.
Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow, orange or white and should be connected to pin 9 on the Arduino board.
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
int pos = 0; // variable to store the servo position
Examples > Servo Library
Sweeps the shaft of a servo motor back and forth.
Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow or orange and should be connected to pin 9 on the Arduino board.
// Sweep
// by BARRAGAN <http://barraganstudio.com>
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}