2
#include <Servo.h> Servo myservo; // create servo object to control a servo Servo myservot; Servo myservott; Servo myservor; Servo myservotr; Servo myservottr; int pos = 0; // variable to store the servo position int arry[]={1108,1109,1150,1200,1500,1600,1650,1651,1652}; int arryu[]={1148,1149,1150,1200,1500,1550,1550,1600,1620}; int arryuu[]={1050,1100,1150,1200,1500,1600,1640,1645,1646}; void setup() { myservo.attach(9); // top servo myservot.attach(10); myservott.attach(11); myservor.attach(3); // bottom servo myservotr.attach(5); myservottr.attach(6); } void loop() { for (pos=0;pos<=8;pos++) { myservo.writeMicroseconds(arry[pos]); // tell servo to go to position in variable 'pos' myservor.writeMicroseconds(arry[8-pos]); // tell servo to go to position in variable 'pos' delay(300); myservot.writeMicroseconds(arryu[pos]); // tell servo to go to position in variable 'pos' myservotr.writeMicroseconds(arryu[8-pos]); // tell servo to go to position in variable 'pos' delay(300);

Code

Embed Size (px)

DESCRIPTION

code

Citation preview

Page 1: Code

#include <Servo.h>

Servo myservo; // create servo object to control a servo

Servo myservot;

Servo myservott;

Servo myservor;

Servo myservotr;

Servo myservottr;

int pos = 0; // variable to store the servo position

int arry[]={1108,1109,1150,1200,1500,1600,1650,1651,1652};

int arryu[]={1148,1149,1150,1200,1500,1550,1550,1600,1620};

int arryuu[]={1050,1100,1150,1200,1500,1600,1640,1645,1646};

void setup()

{

myservo.attach(9); // top servo

myservot.attach(10);

myservott.attach(11);

myservor.attach(3); // bottom servo

myservotr.attach(5);

myservottr.attach(6);

}

void loop()

{

for (pos=0;pos<=8;pos++)

{

myservo.writeMicroseconds(arry[pos]); // tell servo to go to position in variable 'pos'

myservor.writeMicroseconds(arry[8-pos]); // tell servo to go to position in variable 'pos'

delay(300);

myservot.writeMicroseconds(arryu[pos]); // tell servo to go to position in variable 'pos'

myservotr.writeMicroseconds(arryu[8-pos]); // tell servo to go to position in variable

'pos'

delay(300);

myservott.writeMicroseconds(arryuu[pos]); // tell servo to go to position in variable

'pos'

Page 2: Code

myservottr.writeMicroseconds(arryuu[8-pos]); // tell servo to go to position in variable

'pos'

delay(300);

}

for (pos=8;pos>=0;pos--)

{

myservottr.writeMicroseconds(arryuu[8-pos]); // tell servo to go to position in

variable 'pos'

myservott.writeMicroseconds(arryuu[pos]); // tell servo to go to position in variable

'pos'

delay(300);

myservotr.writeMicroseconds(arryu[8-pos]); // tell servo to go to position in variable

'pos'

myservot.writeMicroseconds(arryu[pos]); // tell servo to go to position in variable

'pos'

delay(300);

myservor.writeMicroseconds(arry[8-pos]); // tell servo to go to position in variable

'pos'

myservo.writeMicroseconds(arry[pos]); // tell servo to go to position in variable 'pos'

delay(300);

}