Using a Promini (small to bury in a piece of kinetic art) - powered separately with a “switching” PS (5V,1000ma) and 3 standard servos powered with a 5V 1000ma PS, (common ground) - would you expect the following code to drive the 3 servos independently? They seemed to work at first for some time but then lose control and chattered.
// Sweep
// back and forth rotations of 60 degrees at random times of 5-20 seconds
//upload tp Promini 16mHz using Ardu Duemil 328 board and tty modem
#include <Servo.h> m
Servo myservo9; // create servo object to control a servo
// a maximum of eight servo objects can be created
Servo myservo5;
Servo myservo3;
int pos; // variable to store the servo position
unsigned long pa9;
unsigned long pa5;
unsigned long pa3;
void setup()
{
myservo9.attach(9); // attaches the servo on pin 9 to the servo object
myservo5.attach(5); // attaches the servo on pin 5 to the servo object
myservo3.attach(3); // attaches the servo on pin 3 to the servo object
}
void loop()
{
//for servo9
for(pos = 60; pos < 120; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
{ myservo9.write(pos); // tell servo to go to position in variable 'pos'
delay(45);} // waits 45ms for the servo to reach the position, and the extra curlies slow the servo down
}
pa9=random (10000,40000);
delay (pa9);
for(pos = 120; pos>=60; pos-=1) // goes from 180 degrees to 0 degrees
{
{myservo9.write(pos); // tell servo to go to position in variable 'pos'
delay(45);} // waits 45ms for the servo to reach the position, and the extra curlies slow the servo down
}
pa9=random (10000,40000);
delay (pa9);
//for servo5
for(pos = 60; pos < 120; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
{ myservo5.write(pos); // tell servo to go to position in variable 'pos'
delay(45);} // waits 45ms for the servo to reach the position, and the extra curlies slow the servo down
}
pa5=random (10000,40000);
delay (pa5);
for(pos = 120; pos>=60; pos-=1) // goes from 180 degrees to 0 degrees
{
{myservo5.write(pos); // tell servo to go to position in variable 'pos'
delay(45);} // waits 15ms for the servo to reach the position
}
pa5=random (10000,40000);
delay (pa5);
//for servo3
for(pos = 60; pos < 120; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
{ myservo3.write(pos); // tell servo to go to position in variable 'pos'
delay(45);} // waits 45ms for the servo to reach the position, and the extra curlies slow the servo down
}
pa3=random (10000,40000);
delay (pa3);
for(pos = 120; pos>=60; pos-=1) // goes from 180 degrees to 0 degrees
{
{myservo3.write(pos); // tell servo to go to position in variable 'pos'
delay(45);} // waits 15ms for the servo to reach the position
}
pa3=random (10000,40000);
delay (pa3);
}