positioning a servo before program runs

I’m working on something that requires a servo to be in a certain position (It’s positioned by a 2nd servo) or else the machine will crash. It works fine as long as it’s not powered down at the wrong time but I’d like some sort of failsafe.

Any advise on dealing with this?

I was leaning towards a limit switch that would prevent movement until the motor is in position.

Can you be clearer about the problem? It sounds like you have two servos that must be synchronized in some way but only one of them is controlled by the Arduino?!?

How would having a "limit switch that would prevent movement until the motor is in position" work? It sounds like you want to keep the motor from moving until the motor had moved into position, which makes no sense.

Perhaps if you describe the mechanism and the requirements it would be possible to provide a solution.

Sorry, maybe this will make sense:


I need the servo that turns the US sensor to stay in position until the head clears the slot. There isn't enough room in the case for it to rotate. There is a 2nd servo that raises/lowers the toast and sensor.

Both are controlled by a home made Arduino.


Try this:

const int PINGER_PIN = 9;  // Pinger rotation servo control pin
const int LIFTER_PIN = 8;  // Lifter servo control pin

const int PINGER_PARKED = 0;  // Angle of pinger rotation servo that allows the pinger to retract.
const int LIFTER_BOTTOM = 0;  // Angle of the lifter servo in the lowest position

void setup()
    pingerServo.write(PINGER_PARKED);  // Set initial position of the pinger to the parked position.
    pingerServo.attach(PINGER_PIN);      // Move to parked position
    delay(1000);  // Give the servo plenty of time to reach position

    lifterServo.write(LIFTER_BOTTOM);  // Set initial position of lift arm.

   // The pinger is now in a known position and can be lifted and rotated.

Thanks John!

Do you happen to know anything about subsonic toaster aerodynamics?


Just an update. That worked GREAT! Thanks again for taking the time.