EasyManua.ls Logo

Keyestudio 4DOF - Page 161

Keyestudio 4DOF
276 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
158
if(z1==1) // if the right joystick key is pressed
{
delay(10); // delay for eliminating shake
if(z1==1) // judge again if the right key is pressed
{
s1=myservo1.read(); // read the angle value of each servo
s2=myservo2.read();
s3=myservo3.read();
s4=myservo4.read();
}
}
if(z2==1) // if the left key is pressed
{
delay(10);
if(z2==1)
{
pos1=myservo1.read(); // record the angle value of 4 servos in current posture
pos2=myservo2.read();
pos3=myservo3.read();
pos4=myservo4.read();
if(pos1<s1) // if angle of servo 1 is smaller than variable s1 value
{
while(pos1<s1) //while loop,rotate the servo to the position of the value stored in the array.
{
myservo1.write(pos1); // servo 1 operates the motion