For some reason the following code only works with my Hitech hs422 Servos and not my Savox 0231MG Servos.
Its a simple code. When I flip the switch the servo's are to turn one way and when I unflip the switch it should turn back the other. I have kept everything the same made sure the voltage and amperage is enough.
Is there a difference on how to use code with Savox servos? Is there a problem with my code?
#include <Servo.h>
int button1 = 6; //button pin, connect to ground to move servo
int press1 = 0;
Servo servo1;
void setup()
{
pinMode(button1, INPUT);
servo1.attach(2);
digitalWrite(6, HIGH); //enable pullups to make pin high
}
void loop()
{
press1 = digitalRead(button1);
if (press1 == LOW)
{
servo1.write(0);
}
else {
servo1.write(90);
}
}
Everything is getting power from the Venom 7.4 volt 8000ma battery. In the picture I have the switch being connected to the ground on the arduino, but I have also tried it with it being connected to the ground on the bread board and the results are the same.
Problem is that when I turn the system on, the Savox servo goes to 90 degrees, but never goes back to 0 when I flip the switch. When it's supposed to alternate between 90 and 0 when I flip the switch. It works perfectly with the Hitec Servo.
Looking at the (full) specs for the SW0231MG on the Savox site, it needs a pulse-stream at 200-250hz, instead of the standard servo frequency of 50Hz. I'd say this is your problem.
Also move the power wires of the servo so that they are right next to the power wires from the battery.
The servo must pull quite a bit of current when it start to move, and the protoboard rails are not rated for much current.
Looking at the (full) specs for the SW0231MG on the Savox site, it needs a pulse-stream at 200-250hz, instead of the standard servo frequency of 50Hz. I'd say this is your problem.
Well, I looked at the site servo specs and I did not see anything that states that 200-250hz input pulse stream is required. As it seems the servo can be used with a typical RC receiver, the 200-250hz is probably the spec for the h-bridge driver in the servo.