i created smthing!(a dog feader)

try fixing it tho :frowning:

 #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

maybe you need to add Servo::refresh();

#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’
Servo::refresh();
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’
Servo::refresh();
delay(15); // waits 15ms for the servo to reach the position
}
}
}