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:
#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
for( int i = 0; i < NBR_SERVOS; i++)
Servos*.attach( FIRST_SERVO_PIN +i, 800, 2200);*
- 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?