this wont work, why???

 #include <Servo.h> 
 
Servo myservo;
int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for a pushbutton)
int val = 0;                    // variable for reading the pin status
int pos = 0; 

void setup() 
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
     // declare LED as output
  pinMode(inputPin, INPUT);     // declare pushbutton as input
}

void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
  for(pos = 0; pos < 180; pos += 8)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  }  // turn LED OFF
  } else {
  for(pos = 180; pos>=1; pos-=8)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  }
}

its a function for my auto dog feeder

bump

You haven't told us anything about what you're trying to do, nor in what way it does not work. Please tell us more!