final biped auto code1
FINAL BIPED CODE
#include <Servo.h>
char a;
int p1=90;// initially all the motors are configured to 90.
int p2=90;
int p3=103;
int p4=90;
int p5=77;
int p6=90;
Servo s1;
Servo s2;
Servo s3;
Servo s4;
Servo s5;
Servo s6;
void setup()
{
s1.attach(8);
s2.attach(9);
s3.attach(10);
s4.attach(11);
s5.attach(12);
s6.attach(13);
s1.write(p1);
s2.write(p2);
s3.write(p3);
s4.write(p4);
s5.write(p5);
s6.write(p6);
Serial.begin(9600);
}
void loop()
{
p1=90;
p2=90;
p3=103;
p4=90;
p5=77;
p6=90;
s1.write(p1);
s2.write(p2);
s3.write(p3);
s4.write(p4);
s5.write(p5);
s6.write(p6);
for (; p1 >=68 && p6 >=68 ; p1--)//a-h
{
p6--;
s1.write(p1);
s6.write(p6);
Serial.print("p1=");
Serial.println(p1);
Serial.print("p6=");
Serial.println(p6);
}
delay(500);
for (;p4>=45;p4--)//f
{
s4.write(p4);
Serial.print("p4=");
Serial.println(p4);
}
delay(500);
for (;p5>=51;p5--)//g
{
s5.write(p5);
Serial.print("p5=");
Serial.println(p5);
}
delay(500);
for (; p1 <=119 && p6 <=118 ; p1++)//q-y
{
p6++;
s1.write(p1);
s6.write(p6);
Serial.print("p1=");
Serial.println(p1);
Serial.print("p6=");
Serial.println(p6);
}
delay(500);
for (;p3<=156;p3++)//e
{
s3.write(p3);
Serial.print("p3=");
Serial.println(p3);
}
delay(500);
for (;p2<=132;p2++)//w
{
s2.write(p2);
Serial.print("p2=");
Serial.println(p2);
}
delay(500);
for (; p1 >=88 && p6 >=87 ; p1--)//a-h
{
p6--;
s1.write(p1);
s6.write(p6);
Serial.print("p1=");
Serial.println(p1);
Serial.print("p6=");
Serial.println(p6);
}
delay(500);
for (; p5 <=68 && p2 >=68 ; p5++)//t-s
{
p2--;
s5.write(p5);
s2.write(p2);
Serial.print("p5=");
Serial.println(p5);
Serial.print("p2=");
Serial.println(p2);
}
delay(500);
for (; p3 >=111&& p4 <=90 ; p3--)//d-r
{
p4++;
s3.write(p3);
s4.write(p4);
Serial.print("p3=");
Serial.println(p3);
Serial.print("p4=");
Serial.println(p4);
}
delay(500);
}
Subscribe to:
Posts (Atom)