#include<Wire.h>
#include<Servo.h>
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
int a;
int b;
int c;
int d;
int e;
void setup() {
myservo1.attach(8);
myservo2.attach(9);
myservo3.attach(10);
myservo4.attach(11);
myservo5.attach(7);
myservo1.write(50);
myservo2.write(70);
myservo3.write(70);
myservo4.write(100);
myservo5.write(100);
delay(3000);
}
void loop() {
kanan();
mundur();
turun();
up();
japit();
naik();
down();
maju();
kiri();
mundur();
turun();
up();
lepas();
naik();
down();
maju();
//japit();
//lepas();
}
void kanan() {
for (a = 50; a <= 150; a++) {
myservo1.write(a);
delay(50);
} return;
}
void kiri() {
for (a = 150; a >= 50; a--) {
myservo1.write(a);
delay(50);
}
return;
}
void maju() {
for (b = 100; b >= 70; b--) {
myservo2.write(b);
delay(50);
}
return;
}
void mundur() {
for (b = 70; b <= 100; b++) {
myservo2.write(b);
delay(50);
}
return;
}
void turun() {
for (c = 70; c <= 100; c++) {
myservo3.write(c);
delay(50);
}
return;
}
void naik() {
for (c = 100; c >= 70; c--) {
myservo3.write(c);
delay(50);
}
return;
}
void up() {
for (d = 100; d >= 10; d--) {
myservo4.write(d);
delay(50);
}
return;
}
void down() {
for (d = 10; d <= 100; d++) {
myservo4.write(d);
delay(50);
}
return;
}
void japit() {
for (e = 100; e >= 40; e--) {
myservo5.write(e);
delay(50);
}
return;
}
void lepas() {
for (e = 40; e <= 100; e++) {
myservo5.write(e);
delay(50);
}
return;
}