Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

// Sweep

// by BARRAGAN <http://barraganstudio.com>
#include <Servo.h>
Servo pdret;// create servo object to control a servoint
Servo pesq;// create servo object to control a servoint
Servo cdret;// create servo object to control a servoint
Servo cesq;// create servo object to control a servoint
int pos = 0; // variable to store the servo position
void setup() {
pdret.attach(10);// attaches the servo on pin 9 to the servo object
pesq.attach(11);// attaches the servo on pin 9 to the servo object
cdret.attach(12);// attaches the servo on pin 9 to the servo object
cesq.attach(13);// attaches the servo on pin 9 to the servo object
}
void loop() {
//camina1();
camina2();
//recte();
}
void camina1 (){
int temps=200;
pesq.write(170);// tell servo to go to position in variable 'pos'
delay(temps);
cesq.write(60);// tell servo to go to position in variable 'pos'
delay(temps);
pdret.write(170);// tell servo to go to position in variable 'pos'
delay(temps);
cdret.write(60);// tell servo to go to position in variable 'pos'
delay(temps);// waits 15ms for the servo to reach the position
pesq.write(130);// tell servo to go to position in variable 'pos'
delay(temps);
cesq.write(130);// tell servo to go to position in variable 'pos'
delay(temps);
pdret.write(130);// tell servo to go to position in variable 'pos'
delay(temps);
cdret.write(130);// tell servo to go to position in variable 'pos'
delay(temps);// waits 15ms for the servo to reach the position

}
void camina2 (){
int temps=150;
pesq.write(160);
cesq.write(100);// tell servo to go to position in variable 'pos'
delay(temps);
cdret.write(120);// tell servo to go to position in variable 'pos'
delay(temps);// waits 15ms for the servo to reach the position
pdret.write(170);// tell servo to go to position in variable 'pos'
delay(temps);
cdret.write(80);// tell servo to go to position in variable 'pos'
delay(temps);// waits 15ms for the servo to reach the position
cesq.write(100);// tell servo to go to position in variable 'pos'
delay(temps);
pdret.write(150);// tell servo to go to position in variable 'pos'
delay(50);
pdret.write(150);
cdret.write(80);// tell servo to go to position in variable 'pos'
delay(temps);
cesq.write(70);// tell servo to go to position in variable 'pos'
delay(temps);// waits 15ms for the servo to reach the position
pesq.write(140);// tell servo to go to position in variable 'pos'
delay(temps);
cesq.write(100);// tell servo to go to position in variable 'pos'
delay(temps);// waits 15ms for the servo to reach the position
cdret.write(80);// tell servo to go to position in variable 'pos'
delay(temps);
pesq.write(160);// tell servo to go to position in variable 'pos'
delay(temps);
}
void recte (){
pdret.write(150);// attaches the servo on pin 9 to the servo object
pesq.write(160);// attaches the servo on pin 9 to the servo object
delay (200);
cdret.write(80);// attaches the servo on pin 9 to the servo object
cesq.write(100);// attaches the servo on pin 9 to the servo object
delay(200);
}

You might also like