Hello all,
I am posting today because I am new to Arduino and am seeking help on powering two continuous rotation servo motors (from botbrain.com) that are dependent on two momentary switches. The coding and wiring are very simple (check attached), but I can't seem to understand why only one of my servos work. I believe it is a powering problem but I can't seem to fix the problem.
As you can probably tell from my code, the idea of this sample project is to rotate a motor at a certain speed for a second and a half by pushing the respective button. I am using an external 12V:1A power supply as the supply for the motors. My grounds are connected, as far as I can tell all of my hardware and wiring is correct.
Here is my code:
#include <Servo.h>
Servo servoleft;
Servo servoright;
const int leftButton = 9;
const int rightButton = 11;
int selection1SwitchState = LOW;
int selection2SwitchState = LOW;
void setup() {
pinMode( leftButton, INPUT );
pinMode( rightButton, INPUT );
servoleft.attach (3);
servoleft.write (90);
servoright.attach (5);
servoright.write (90);
}
void loop() {
selection1SwitchState = digitalRead ( leftButton );
selection2SwitchState = digitalRead ( rightButton );
if (selection1SwitchState == HIGH && selection2SwitchState == LOW) {
servoleft.write (110);
delay(1500);
servoleft.write (90);
selection1SwitchState = LOW;
}
if (selection2SwitchState == HIGH && selection1SwitchState == LOW) {
servoright.write (110);
delay(1500);
servoright.write (90);
selection2SwitchState = LOW;
}
}
So I uploaded my code to the uno, and when I press button 1, motor 1 does exactly what it should. Where I encounter problems is when I press the second button, nothing happens. I can't seem to understand why its like the second motor is not even there. There is no subtle movements in the motor or even buzzing (as the motors attempt to work.)
Does anyone know what the problem could be? Im stuck, and I've tried everything that I could think of.
One last question is,is there another way to code these motors? Ive seen a way online using pulses and such but I really don't understand that to well.
Thanks in advance and your help is greatly appreciated,
Ro

