Tuesday, March 16, 2010

Coding of the 1st prototype

1st: Motor which control the movement of up and down

#include

Servo myservo;
boolean switchReading;
boolean rotateDirection = true;

void setup()
{
myservo.attach(9);
pinMode(7, INPUT);
myservo.write(90);
}

void loop()
{
switchReading = digitalRead(7);
if(switchReading == true)
{
if(rotateDirection == true)
{
myservo.write(85);
delay(3000);
} else if(rotateDirection == false)
{
myservo.write(95);
delay(3000);
}
rotateDirection = !rotateDirection;
} else if(switchReading == false)
{
myservo.write(90);
}
}

2nd: Motor which control the rotation

#include

Servo myservo;
int t;

void setup()
{
myservo.attach(9);
myservo.write(10);
delay(3000);
}

void loop()
{
for(int i = 10; i < i =" 170;"> 10; i--){
myservo.write(i);
delay(10);
}
}

No comments:

Post a Comment