Hi,
I got some problem with my arduino code.
Actually I want my servomotor turns one after other.
But at the beginning, the three turns in the same time, and after turn one by one.
If you know how solve this problem.
I use Tinkercad.
Here the code I using:
#include <Servo.h>
Servo myservo1; // create servo object to control a servo
Servo myservo2;
Servo myservo3;
int pos1 = 0; // variable to store the servo’s starting position
int pos2 = 0;
int pos3 = 90;
void setup()
{
Serial.begin(9600);
myservo1.attach(9); // attaches the servo on pin 9 to the servo object
myservo2.attach(10); // attaches the servo on pin 10 to servo object
myservo3.attach(11); // attaches the servo on pin 11 to servo object
}
void loop(){
for (int position = 0; position <= 90; position++) {
myservo1.write(position);
delay(15);
}
for (int position = 90; position >= 0; position--) {
myservo1.write(position);
delay(20);
}
for (int position = 0; position <= 90; position++) {
myservo2.write(position);
delay(25);
}
for (int position = 90; position >= 0; position--) {
myservo2.write(position);
delay(25);
}
for (int position = 90; position <= 180; position++) {
myservo3.write(position);
delay(25);
}
for (int position = 180; position >= 90; position--) {
myservo3.write(position);
delay(50);
}
}
It's from another site, I don't remember who
Thanks for your answers