Mientras terminaba de desempacar los productos enviados desde China; se me venian a la cabeza la posibilidades para cada uno de ellos y sus vinculaciones.
Entonces empecemos con una sencilla. Mover los servos utilizando el Joystick Shield.
Elementos a utilizar:
Iteaduino Leonardo
Pan/Tilt Bracket (Paneos)
Servos
Protoboards
Jumpers
Joystick Shield
Y ganas de probar y cambiar codigo y cables ;-)
Codigo Fuente: (mediafire)
(parcial)
void setup() {
Serial.begin(9600);
servoTilt.attach(2); //The Tilt servo is attached to pin 2.
servoPan.attach(1); //The Pan servo is attached to pin 3.
pinMode(button0, INPUT); //Set the Joystick button 0 as an input
digitalWrite(button0, HIGH); //Enable the pull-up resistor on button 0
pinMode(button1, INPUT); //Set the Joystick button 1 as an input
digitalWrite(button1, HIGH); //Enable the pull-up resistor on button 1
pinMode(button2, INPUT); //Set the Joystick button 2 as an input
digitalWrite(button2, HIGH); //Enable the pull-up resistor on button 2
pinMode(button3, INPUT); //Set the Joystick button 3 as an input
digitalWrite(button3, HIGH); //Enable the pull-up resistor on button 3
valCambio=0;
}
void loop() {
val = analogRead(PIN_ANALOG_X);
val = map(val, 0, 1023, 0, 180);
if(valCambio==0){
servoTilt.write(val);
valCambio=1;
}else{
servoPan.write(val);
valCambio=0;
}
delay(20);
}
Entonces empecemos con una sencilla. Mover los servos utilizando el Joystick Shield.
Elementos a utilizar:
Iteaduino Leonardo
Pan/Tilt Bracket (Paneos)
Servos
Protoboards
Jumpers
Joystick Shield
Y ganas de probar y cambiar codigo y cables ;-)
Codigo Fuente: (mediafire)
(parcial)
void setup() {
Serial.begin(9600);
servoTilt.attach(2); //The Tilt servo is attached to pin 2.
servoPan.attach(1); //The Pan servo is attached to pin 3.
pinMode(button0, INPUT); //Set the Joystick button 0 as an input
digitalWrite(button0, HIGH); //Enable the pull-up resistor on button 0
pinMode(button1, INPUT); //Set the Joystick button 1 as an input
digitalWrite(button1, HIGH); //Enable the pull-up resistor on button 1
pinMode(button2, INPUT); //Set the Joystick button 2 as an input
digitalWrite(button2, HIGH); //Enable the pull-up resistor on button 2
pinMode(button3, INPUT); //Set the Joystick button 3 as an input
digitalWrite(button3, HIGH); //Enable the pull-up resistor on button 3
valCambio=0;
}
void loop() {
val = analogRead(PIN_ANALOG_X);
val = map(val, 0, 1023, 0, 180);
if(valCambio==0){
servoTilt.write(val);
valCambio=1;
}else{
servoPan.write(val);
valCambio=0;
}
delay(20);
}
Comentarios