#include <Servo.h>
Servo servo;
const byte PinBut   = A5;
const byte PinServo = A0;
byte butState;
// -----------------------------------------------------------------------------
bool
isPressed ()
{
    byte but = digitalRead (PinBut);
    if (butState != but){
        butState = but;
        delay (30);
        return LOW == but;
    }
    return false;
}
// -----------------------------------------------------------------------------
void loop ()
{
    if (isPressed ()) {
        int deg = servo.read ();
        if (180 == deg)
            servo.write (0);
        else
            servo.write (180);
    }
}
// -----------------------------------------------------------------------------
void setup ()
{
    pinMode (PinBut, INPUT_PULLUP);
    butState = digitalRead (PinBut);
    servo.attach (PinServo);
}