#include <Servo.h>
Servo legtakaoik;
Servo legtakavas;
Servo legetuoik;
Servo legetuvas;
Servo legtakaoikup;
Servo legtakavasup;
Servo legetuoikup;
Servo legetuvasup;
int eteen;
boolean jalka;
void setup()
{
legtakaoik.attach(9);
legtakavas.attach(10);
legetuoik.attach(8);
legetuvas.attach(7);
legtakaoikup.attach(6);
legtakavasup.attach(5);
legetuoikup.attach(4);
legetuvasup.attach(3);
}
void loop() {
etuvas(90, false); // all servos to 90 degrees = center
etuoik(90, false); // false = leg down, true = leg up
takavas(90, false);
takaoik(90, false);
delay(200);
eteen=10; // For testing only. Move forward 10 steps.
delay(4000);
for (int i=0;i<eteen;i++) // go forward
{
if (i=0) { // first step
etuvas(120, true); // move servo 120 degrees
takaoik(120, true);
delay(200);
}
else {
etuoik(60, false);
takavas(60, false);
delay(360);
etuvas(120, true);
takaoik(120, true);
delay(360);
}
etuoik(120, true);
takavas(120, true);
delay(360);
etuvas(60, false);
takaoik(60, false);
delay(360);
}
}
void etuvas(int i, boolean jalka) { // front left foot
legetuvas.write(i);
if (jalka == true)
legetuvasup.write(180);
else
legetuvasup.write(0);
}
void etuoik(int i, boolean jalka) { // front right foot
legetuoik.write(i);
if (jalka == true)
legetuoikup.write(180);
else
legetuoikup.write(0);
}
void takavas(int i, boolean jalka) { // rear left foot
legtakavas.write(i);
if (jalka == true)
legtakavasup.write(180);
else
legtakavasup.write(0);
}
void takaoik(int i, boolean jalka) { // rear right foot
legtakaoik.write(i);
if (jalka == true)
legtakaoikup.write(180);
else
legtakaoikup.write(0);
}
Servo legtakaoik;
Servo legtakavas;
Servo legetuoik;
Servo legetuvas;
Servo legtakaoikup;
Servo legtakavasup;
Servo legetuoikup;
Servo legetuvasup;
int eteen;
boolean jalka;
void setup()
{
legtakaoik.attach(9);
legtakavas.attach(10);
legetuoik.attach(8);
legetuvas.attach(7);
legtakaoikup.attach(6);
legtakavasup.attach(5);
legetuoikup.attach(4);
legetuvasup.attach(3);
}
void loop() {
etuvas(90, false); // all servos to 90 degrees = center
etuoik(90, false); // false = leg down, true = leg up
takavas(90, false);
takaoik(90, false);
delay(200);
eteen=10; // For testing only. Move forward 10 steps.
delay(4000);
for (int i=0;i<eteen;i++) // go forward
{
if (i=0) { // first step
etuvas(120, true); // move servo 120 degrees
takaoik(120, true);
delay(200);
}
else {
etuoik(60, false);
takavas(60, false);
delay(360);
etuvas(120, true);
takaoik(120, true);
delay(360);
}
etuoik(120, true);
takavas(120, true);
delay(360);
etuvas(60, false);
takaoik(60, false);
delay(360);
}
}
void etuvas(int i, boolean jalka) { // front left foot
legetuvas.write(i);
if (jalka == true)
legetuvasup.write(180);
else
legetuvasup.write(0);
}
void etuoik(int i, boolean jalka) { // front right foot
legetuoik.write(i);
if (jalka == true)
legetuoikup.write(180);
else
legetuoikup.write(0);
}
void takavas(int i, boolean jalka) { // rear left foot
legtakavas.write(i);
if (jalka == true)
legtakavasup.write(180);
else
legtakavasup.write(0);
}
void takaoik(int i, boolean jalka) { // rear right foot
legtakaoik.write(i);
if (jalka == true)
legtakaoikup.write(180);
else
legtakaoikup.write(0);
}
No comments:
Post a Comment