make servo rotate 90 degree

Could make servo rotate 90 degree when switch on and when switch off return to the original...
if can do it , please post the code . :slight_smile:

when switch off return to the original...
if can do it

Do you want the servo to move after the Arduino is turned off or after a switch is turned off ?

when turn off the switch

Just so I have got this right.

When the switch is in one position the servo moves to 0 degrees and when it is in the second position the servo moves to 90 degrees. The Arduino remains powered at all times. Is that right ?

Have you tried the Servo and Button examples in the IDE ?

Very simple servo button code.

//zoomkat servo button test 7-30-2011
//Powering a servo from the arduino usually *DOES NOT WORK*.

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(160);
  }
  else {
    servo1.write(20);
  }
}

right... The Arduino remains powered at all times

Try the code posted by zoomkat