Biped

BIPED :--



ADJUSTING MOTOR TO 90:


#include <Servo.h>

Servo myservo; 
void setup()
{
  myservo.attach(9);  }


void loop()
{
  myservo.write(90);


my first biped with 6motors  .
'






Testing program :
 /*   for the motors as shown above , each are
connected as shown in 123456 and now we assign qwerty,asdfgh
 to fwd and backward respectively. */

 #include <Servo.h>


char a;

 int p1=90;// initially all the motors are configured to 90.
 int p2=90;
 int p3=90;
 int p4=90;
 int p5=90;
 int p6=90;
 int p7=90;


 Servo s1;
 Servo s2;
 Servo s3;
 Servo s4;
 Servo s5;
 Servo s6;
 Servo s7;


 void setup()
 {
   s1.attach(8);
   s2.attach(9);
   s3.attach(10);
   s4.attach(11);
   s5.attach(12);
   s6.attach(13);
   s7.attach(7);
    s1.write(p1);
    s2.write(p2);
    s3.write(p3);
    s4.write(p4);
    s5.write(p5);
    s6.write(p6);
    s7.write(p7);
 
   Serial.begin(9600);
 
 }

 void loop()
 {
   if (Serial.available() > 0) {
     a = Serial.read();
    Serial.print("1.");
    Serial.println(a);
  }

  switch(a)
  {
 
    //1 f
    case 'q':
    Serial.println("q");
    if (p1>=0 && p1<180)
    {
    p1=p1+1;
    s1.write(p1);
    Serial.print("p1=");
    Serial.println(p1);
     
    }
    else
 
   Serial.println("INVALID");

   break ;
   //1 B
 
   case 'a':
    if (p1<=180 && p1>0)
    {
    p1=p1-1;
    s1.write(p1);
     Serial.print("p1=");
    Serial.println(p1);
    }
    else
 
   Serial.println("INVALID");
 
   break;
 
   //2.f
      case 'w':
    Serial.println("w");
    if (p2>=0 && p2<180)
    {
    p2=p2+1;
    s2.write(p2);
        Serial.print("p2=");
    Serial.println(p2);
    }
    else
 
   Serial.println("INVALID");
 
   break ;
   //2 B
 
   case 's':
    if (p2<=180 && p2>0)
    {
    p2=p2-1;
    s2.write(p2);
    Serial.print("p2=");
    Serial.println(p2);
     
    }
    else
 
   Serial.println("INVALID");
 
  break;
   //3.f
      case 'e':
    Serial.println("e");
    if (p3>=0 && p3<180)
    {
    p3=p3+1;
    s3.write(p3);
    Serial.print("p3=");
    Serial.println(p3);
     
    }
    else
 
   Serial.println("INVALID");
 
   break ;
   //3 B
 
   case 'd':
    if (p3<=180 && p3>0)
    {
    p3=p3-1;
    s3.write(p3);
        Serial.print("p3=");
    Serial.println(p3);
    }
    else
 
   Serial.println("INVALID");
   ;
  break;
   //4.f
      case 'r':
    Serial.println("r");
    if (p4>=0 && p4<180)
    {
    p4=p4+1;
    s4.write(p4);
        Serial.print("p4=");
    Serial.println(p4);
    }
    else
 
   Serial.println("INVALID");
 
   break ;
   //4 B
 
   case 'f':
    if (p4<=180 && p4>0)
    {
    p4=p4-1;
    s4.write(p4);
    Serial.print("p4=");
    Serial.println(p4);
     
    }
    else
 
   Serial.println("INVALID");
 
  break;

    //5.f
      case 't':
    Serial.println("t");
    if (p5>=0 && p5<180)
    {
    p5=p5+1;
    s5.write(p5);
    Serial.print("p5=");
    Serial.println(p5);
     
    }
    else
 
   Serial.println("INVALID");
 
   break ;
   //5 B
 
   case 'g':
    if (p5<=180 && p5>0)
    {
    p5=p5-1;
    s5.write(p5);
        Serial.print("p5=");
    Serial.println(p5);
    }
    else
 
   Serial.println("INVALID");
 
  break;

    //6.f
      case 'y':
    Serial.println("y");
    if (p6>=0 && p6<180)
    {
    p6=p6+1;
    s6.write(p6);
        Serial.print("p6=");
    Serial.println(p6);
    }
    else
 
   Serial.println("INVALID");
   Serial.print("p6=");
    Serial.println(p6);
   break ;
   //6 B
 
   case 'h':
    if (p6<=180 && p6>0)
    {
    p6=p6-1;
    s6.write(p6);
    Serial.print("p6=");
    Serial.println(p6);
     
    }
    else
 
   Serial.println("INVALID");
 
  break;
  //torso
  case 'p':
    Serial.println("p");
    if (p7>=0 && p7<180)
    {
    p7=p7+1;
    s7.write(p7);
        Serial.print("p7=");
    Serial.println(p7);
    }
    else
 
   Serial.println("INVALID");
   Serial.print("p6=");
    Serial.println(p6);
   break ;
 
 case 'l':
    if (p7<=180 && p7>0)
    {
    p7=p7-1;
    s7.write(p7);
    Serial.print("p7=");
    Serial.println(p7);
     
    }
    else
 
   Serial.println("INVALID");
 
  break;
 
  }
  a='\0';
 
 }