I have to control 3 servos on an Arduino Uno. I have written the program and two of the motors seem to work but the third is not responding at all.
/*
Arduino Servo Test sketch
*/ #include <Servo.h>
Servo servoAngler; // Main brace angle servo
Servo servoStopper; // Arm Holding Servo
Servo servoTensioner; // Spring Tension Servo
void setup()
{
servoAngler.attach(10); // servo on digital pin 10
servoStopper.attach(6); // servo on digital pin 6
servoTensioner.attach(3); //servo on digital pin 3
}
void loop()
{
servoStopper.write(0); // Turn Servo Left to 0 degrees
delay(1000); // Wait 1 second
servoAngler.write(90); // Turn Servo to center position (90 degrees)
delay(1000); // Wait 1 second
servoTensioner.write(180); // Turn Servo Right to 180 degrees
delay(1000); // Wait 1 second
servoStopper.write(90); // Turn Servo back to center position (90 degrees)
delay(1000); // Wait 1 second
servoTensioner.write(0); // Turn Servo Left to 0 degrees
delay(5000); // Wait 5 second
servoAngler.write(0); // Turn Servo Left to 0 degrees
delay(1000); // Wait 1 Second
}
Any ideas as to why it wouldn't work? There is power going to the servo.
Anything Helps. This is my first time using this program
The code looks fine so I would guess that there might be a hardware/wiring error.
If you swap a working servo for the non-working servo does the problem follow the servo or stay with the I/O pin? If it follows the servo the servo may be faulty. If it stays with the I/O pin then perhaps the pin is bad and you should try another pin.
I was talking about the the stopper servo, sorry about that. But I did test the servo and it does seem faulty. Is there any way for me to make all of the servos go through the program except have one of the function wired to pushing a button and then have the rest of the program to continue. For ex:
#include <Servo.h>
Servo servoAngler; // Main brace angle servo
Servo servoStopper; // Arm Holding Servo
Servo servoTensioner; // Spring Tension Servo
void setup()
{
servoAngler.attach(10); // servo on digital pin 10
servoStopper.attach(6); // servo on digital pin 6
servoTensioner.attach(3); //servo on digital pin 3
}
void loop()
{
servoStopper.write(0); // Turn Servo Left to 0 degrees
delay(1000); // Wait 1 second
servoAngler.write(90); // Turn Servo to center position (90 degrees)
delay(1000); // Wait 1 second
servoTensioner.write(180); // Turn Servo Right to 180 degrees
delay(1000); // Wait 1 second
servoStopper.write(90); // Turn Servo back to center position (90 degrees) ----- I want this command to be wired on a push button.
delay(1000); // Wait 1 second
servoTensioner.write(0); // Turn Servo Left to 0 degrees
delay(5000); // Wait 5 second
servoAngler.write(0); // Turn Servo Left to 0 degrees
delay(1000); // Wait 1 Second
}
Is there any way for me to make all of the servos go through the program except have one of the function wired to pushing a button and then have the rest of the program to continue.
That is way too imprecise to understand exactly what you want to do.
The way you have written it with all those long delays then there is no way it will respond to a push button. You will have to rewrite it properly using the technique shown in the blink without delay example.
Twice you haven't put the proper code tags in a post.
Select the code and hit the # icon, you can modify your existing posts now.
/*
Arduino Servo Test sketch
*/ #include <Servo.h>
Servo servoAngler; // Main brace angle servo
Servo servoStopper; // Arm Holding Servo
Servo servoTensioner; // Spring Tension Servo
void setup()
{
servoAngler.attach(10); // servo on digital pin 10
servoStopper.attach(6); // servo on digital pin 6
servoTensioner.attach(3); //servo on digital pin 3
}
void loop()
{
servoStopper.write(0); // Turn Servo Left to 0 degrees
servoAngler.write(90); // Turn Servo to center position (90 degrees)
servoTensioner.write(180); // Turn Servo Right to 180 degrees
servoStopper.write(90); // Turn Servo back to center position (90 degrees)
servoTensioner.write(0); // Turn Servo Left to 0 degrees
delay(5000); // Wait 5 seconds
[/color] servoAngler.write(0); // Turn Servo Left to 0 degrees
}
This is how I have chosen to write the program without delays. Any suggestions, the servos are not moving full speed?