Inmoov bot : Eye movement and laugh in arduino sketch using Induino R5


#include <Servo.h>
 
int eyeLRServopin = 4;
int servoMouthPin = 7;
int eyeTDServopin = 8;

Servo servoEyeLR,servoMouth,servoEyeTD;  
 
int servoAngle = 0;   // servo position in degrees
int laughCount=0;
int eyesPosition;
void setup()
{
  servoEyeLR.attach(eyeLRServopin);
  servoMouth.attach(servoMouthPin);
  servoEyeTD.attach(eyeTDServopin);
  
  pinMode(12,OUTPUT);
  pinMode(13,OUTPUT);

  resetPosition();
  delay(2000);          
 
}
 
 
void loop()
{
//control the servo's direction and the position of the motor
 
   digitalWrite(12, HIGH);//led
   digitalWrite(13, LOW);//led

   servoEyeLR.write(0);  
   delay(2000);          
   servoEyeLR.write(180);     
   delay(2000);          

   servoEyeLR.write(90);//reset eyeLR
    
   servoEyeTD.write(0);  
   delay(2000);          
   servoEyeTD.write(180);     
   delay(2000);          

   servoEyeTD.write(90);//reset eyeTD
//
//    for(eyesPosition=0;eyesPosition<=180;eyesPosition++) // { // servoEyeLR.write(eyesPosition); // delay(500); // servoEyeTD.write(eyesPosition); // delay(500); // } // // for(eyesPosition=180;eyesPosition>=0;eyesPosition--)
//    {
//      servoEyeLR.write(eyesPosition);
//      delay(500);
//      servoEyeTD.write(eyesPosition);
//      delay(500);
//    }

   resetPosition();

    for(laughCount=0;laughCount<10;laughCount++)
    {
     servoMouth.write(0);  
     delay(100);          
  
     servoMouth.write(180);     
     delay(100);          
    }

   //reset
  resetPosition();
  delay(2000);          

}

void resetPosition()
{
    servoEyeLR.write(90);  
    servoMouth.write(90); 
    servoEyeTD.write(90);
}

About PraveenMax
My Interests: ------------------ Programming , Drawing & Music

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: