hello trying make multiple servo motors rotate 0 90 degrees @ same time. using motor shield enables me rotate multiple ones external power source no problems getting them rotate. issue current code using enables motors rotate 1 after other. want them rotate in unison. please me figure out how write code enables motors rotate @ same time?
#include <servo.h>
servo myservo1;
servo myservo2;
servo myservo3;
servo myservo4;
void setup()
{
myservo1.attach(0);
myservo2.attach(2);
myservo3.attach(4);
myservo4.attach(6);
}
void loop()
{
myservo1.write(0);
delay(1000);
myservo1.write(90);
delay(1000);
myservo2.write(0);
delay(1000);
myservo2.write(90);
delay(1000);
myservo3.write(0);
delay(1000);
myservo3.write(90);
delay(1000);
myservo4.write(0);
delay(1000);
myservo4.write(90);
delay(1000);
}
#include <servo.h>
servo myservo1;
servo myservo2;
servo myservo3;
servo myservo4;
void setup()
{
myservo1.attach(0);
myservo2.attach(2);
myservo3.attach(4);
myservo4.attach(6);
}
void loop()
{
myservo1.write(0);
delay(1000);
myservo1.write(90);
delay(1000);
myservo2.write(0);
delay(1000);
myservo2.write(90);
delay(1000);
myservo3.write(0);
delay(1000);
myservo3.write(90);
delay(1000);
myservo4.write(0);
delay(1000);
myservo4.write(90);
delay(1000);
}
yup, you've got delay. you've written says move servo 1 0, go coma second, move servo 1 90, go coma second...
look @ "blink without delay" example inspiration on how handle timing without using delay.
look @ "blink without delay" example inspiration on how handle timing without using delay.
Arduino Forum > Using Arduino > Programming Questions > Multi-Servo rotation
arduino
Comments
Post a Comment