Hello, rookie here in need of some assistance.
I am building a little robot for demonstration purposes, which is nothing more than five microservos (TS90A and MS18) following a repetitive set of commands to pick up a ball and place it at the top of a ramp, repeat. I have it running this cycle each time I press a button.
When connected to the computer via USB, the program runs just fine and the robot moves exactly how I want it to. When I connect it to a 9Vdc 300mA power supply plugged into the wall, it behaves completely differently, and without consistency. It jerks around and moves very slowly through motions that are not a part of the code.
I ultimately want to be able to plug this thing into the wall and let it run this simple demonstration on loop over and over. Why the different behavior from the USB to the DC power supply? Any advice would be appreciated.
#include<VarSpeedServo.h>
int switchState = 0;
//define variables and constants
VarSpeedServo robotBase;
VarSpeedServo robotClaw;
VarSpeedServo bigArm;
VarSpeedServo littleArm;
VarSpeedServo gate;
void setup() {
robotBase.attach(10);
robotClaw.attach(9);
bigArm.attach(6);
littleArm.attach(11);
gate.attach(5);
pinMode(2, INPUT);
} //end of setup()
//loop function
void loop() {
switchState = digitalRead(2);
if (switchState == HIGH) {
robotBase.write(155,60,true);
bigArm.write(60,100,true);
delay(1000);
littleArm.write(90,60,true);
bigArm.write(108,60,true);
delay(1000);
gate.write(180,100,true);
delay(2000);
robotClaw.write(0,60,true);
delay(1000);
bigArm.write(60,60,true);
littleArm.write(120,60,true);
robotBase.write(112,60,true);
littleArm.write(180,60,true);
bigArm.write(120,60,true);
delay(1000);
gate.write(90,100,true);
robotClaw.write(50,60,true);
delay(1000);
bigArm.write(60,60,true);
delay(1000);
}
} //end of loop()
