  servo1.attach(servoPin);
  pinMode(  switchPin1,INPUT );
  pinMode(  switchPin2,INPUT );  
+ pinMode( ledPin, OUTPUT);
+ Serial.begin(9600);
+ 
 }
 
 void loop(){

  else if(digitalRead(switchPin2) == HIGH){
   rotateRight(); 
  }
  
  
}

void rotateLeft(){
  for(; servoPos > 0; servoPos--){
   servo1.write(servoPos);
   delay(20);
   if(digitalRead(switchPin1) == HIGH){
    return; 
   }
   
   else if(digitalRead(switchPin2) == HIGH){
     rotateRight();
     return;     
   }
  }
  
}


void rotateRight(){
 for(; servoPos < 180; servoPos++){
   servo1.write(servoPos);
   delay(20);
   if(digitalRead(switchPin1) == HIGH){
     rotateLeft();
     return; 
   }
   else if(digitalRead(switchPin2) == HIGH){
     return;   
   }
  }
  
}



// constant declerations
Servo servo1;
const int servoPin = 11;
const int switchPin1=2;
const int switchPin2 = 4;
const int ledPin = 3;

int servoPos =0;

