Keyestudio 4DOF Manual page 150

Robot arm kit
Hide thumbs Also See for 4DOF:
Table of Contents

Advertisement

www.keyestudio.com
void loop()
{
myservo1.attach(A1); // set the control pin of servo 1 to A1
myservo2.attach(A0); // set the control pin of servo 2 to A0
myservo3.attach(6);
myservo4.attach(9);
x1 = analogRead(right_X); // read the right X value
y1 = analogRead(right_Y); //read the right Y value
z1 = digitalRead(right_key); //read the right Z value
x2 = analogRead(left_X); // read the left X value
y2 = analogRead(left_Y); // read the left Y value
z2 = digitalRead(left_key); // read the left Z value
//delay(5); // delay, used to reduce the joystick value read, that is reduce the whole speed.
if(z1==1)
// if the joystick right 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 servo 1 and assign it to s1
delay(100);
Serial.println(s1); // print out the angle value of servo 1 on the serial monitor
s2=myservo2.read(); // read the angle value of servo 2 and assign it to s2
delay(100);
Serial.println(s2);
s3=myservo3.read();
delay(100);
Serial.println(s3);
//set the control pin of servo 3 to D6
// set the control pin of servo 4 to D9
// read the angle value of servo 3 and assign it to s3
147

Advertisement

Table of Contents
loading

Table of Contents