I have a robot that uses an Arduino Mega to control two giant scale servos.
The servos have their own separate power supply.
In my sketch I set the the initial position of the servos in the setup function.
servo1.write(60); //set servos to back/middle position
servo2.write(120);
This is a default position the servos resolve to when they are not in use and when the robot shuts down.
If I power up the Arduino first then then servos second there is no initial sweep, and the servos behave as expected.
I added a rf remote on/off switch to the robot that supplies power to the Arduino and servos at the same time.
When the Arduino and servos get power simultaneously, the servos do a rapid sweep then set to the correct position specified in the setup function.
Is there a way to eliminate this initial sweep? If the servos are already at the default position when the robot is off, why does it sweep away and back on startup?
I still get the same sweep if I write position before attaching pins.
I think I need to introduce mosfets to control power sequence. Servos are sweeping because they get power but they don't have a control signal until Arduino comes online a fraction of a second later? So I need to get Arduino online first then use it to control a mosfet which powers servos.