Servo Control using Pushbutton I was trying to build a system that when the user pushes the button, the servo rotates 45 degrees and than returns back to zero. This system is going to be duplicated as there will be two servos and pushbuttons. 

Here's my code:

#include &lt;Servo.h&gt;
Servo solservo;  // create servo object to control a servo
Servo sagservo;
// twelve servo objects can be created on most boards

int possol = 0;    // variable to store the servo position
int possag = 0;
int degsol=0;
int degsag=0;

int ledPin = 13; // choose the pin for the LED
int solPin = 7;   // Pushbutton
int sagPin = 8;     // variable for reading the pin status
int valsag = 0;
int valsol = 0;

void setup() {
  solservo.attach(9);  // attaches the servo on pin 9 to the servo object
  sagservo.attach(10);
  pinMode(solPin, INPUT);
  pinMode(sagPin, INPUT);
  pinMode(ledPin, OUTPUT);


}

void loop() {
  digitalWrite(ledPin, HIGH);    //Arka İsik
  valsag = digitalRead(sagPin);  // read input value
  valsol = digitalRead(solPin);
//Sag Servo

  if (valsag == HIGH) {   
    sagservo.write(45);              // tell servo to go to position in variable 'pos'
    delay(100);                       // waits 15ms for the servo to reach the position
    sagservo.write(-45);

  }
//Sol Servo  
  if (valsol == HIGH){
    solservo.write(45);
    delay(15);
    solservo.write(0);
  }  

}  


There'll probably be lots of small errors in this code, like unnecessary ints and such, but when I upload this program and push the button, it just rotates 45 deg, and doesn't come back. Is there a way that I can solve it?

Thanks in advance
Change sagservo.write(-45); to sagservo.write(0);.