servo programming

So i have a servo and i want it to move 180 when i flip a switch and stay there until i flip the switch again and it moves 180 the opposite ways and stay there i need a code to put in my arduino to do that please help

Maybe something close:

//zoomkat servo button test 12-29-2011

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

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

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(170);
  }    
  
  press2 = digitalRead(button2);
  if (press2 == LOW)
  {
    servo1.write(10);
  }
}

Check whether your servo can actually provide a full 180 degree rotation - not all servos can.

Pseudo code

set angle variable to 0

start of loop
  if switch is closed
      if angle is 0
        set angle to 180
      end of if
    else
      set angle to 0
    end of else
    servo.write(angle)
  end of if
end of loop

Debouncing the switch would be a good idea