Hello,I'm new here and I just wanted to show someone some of the code I'm using to control an animatronic figure with the arduino.The circuit is very simple.It is a potentiometer attached to analog pin 0, with the signal lines for 7 servos controlled via pins 2 through 8.I am using the MegaServo library and the example in this exercise.The forum won't let me post the link because it is my first post, so I will post video of it on youtube after I post this.
Here is the code:
#include <MegaServo.h> #define NBR_SERVOS 12 // the number of servos, up to 48 for Mega, 12 for other boards #define FIRST_SERVO_PIN 2
MegaServo Servos[NBR_SERVOS] ; // Create servo object to control maximum number of 12 servos
int pos = 0; // variable to store the servo position
int potPin = 0; // connect a pot to this pin.This is the analog 0
void setup()
{
for( int i = 0; i < NBR_SERVOS; i++)
Servos*.attach( FIRST_SERVO_PIN +i, 800, 2200);* } void loop() {
pos = analogRead(potPin); // read a value from 0 to 1023*
for( int i =0; i <NBR_SERVOS; i++)*
_ Servos*.write(map(pos, 0,1023,0,180)); // sets the servo position according to the scaled value*_
} What I noticed about this is one of the servos seems to lock in place.Can anyone tell me what I can do to fix this?
Thanks.This piece is actually going to be taken to horror conventions with me here in the U.S. (I'm an Effects artist if I hadn't mentioned it before.).When finished it will look like a life sized doll with a crack running down its face.Pretty creepy, I guess.
But here's my question to anyone that can give me insight.If you look on the vid, the right arm seizes up.Keep in mind its controlled by hobby servos.Is there something I can do to fix this?
Thanks for the kind words.I'm glad you guys like it.But to answer the question about the circuit design, I can't post a diagram right now, but I will tell you that the power supply is 6 volts and the servo signal lines are attached to pins 2 through 8. The middle leg of the pot is attached to analog 0.
I'm thinking it may be a conflicting hardware problem.The servos are two different models.I have fixed this on a PIC by isolating servos to a separate port from the input, but with the arduino I really don't know enough yet to do much.
I'm thinking it may be a conflicting hardware problem.The servos are two different models.I have fixed this on a PIC by isolating servos to a separate port from the input
I am unclear what you are saying. what kind of conflict?
If you exchange ports between the problem servo and one that works ok, does the problem swap, or does it stay with the servo?
Sorry,I really wasn't very clear.When used the pic, I figured out that as long as all of the servos(regardless of model) were on port b, they worked fine.I move the input device(in that particular case, a set of photocells) to port a. This seemed to work well.All of the servos functioned and none of them seized up.
On the arduino, the s3003 futaba servos seem to be seizing up.I'm using s3004 and s3003.Have you ever heard of a problem similar to this?