#include <Servo.h>

#define SERVO 9 // pin to which servo is connected 
#define BUTTON 7 // pin to which the button is connected 

#define SERVO_POS_ON 90   // position of servo when button is pressed
#deinfe SERVO_POS_OFF 0		// position of servo when button is released 
Servo servo;

void setup() {
servo.attach(SERVO);
pinMode(BUTTON, INPUT_PULLUP); // connect pin 7 to ground 
servo.write(SERVO_POS_OFF);
}

void loop() {
 if(!digitalRead(BUTTON))
servo.write(SERVO_POS_ON);
else
servo.write(SERVO_POS_OFF);

}