servo turns 180 degrees then waits 2 seconds then turns 180 degrees

Hello, I need help on making an arduino project. I want it so that the servo turns 180 degress then waits a few seconds then turns back 180 degrees. I tried using a delay but that just makes the servo turn forever. plz help

(deleted)

my code??

Remember that the loop function gets repeated over and over again. Anything you put in there will hapen again and again. If you want something to happen only once on startup then put that in setup instead of loop.

help-me-please:
my code??

Yes the code that you wrote and are now having trouble with.

#include <Servo.h>

Servo myservo;

void setup()
{
myservo.attach (9);
}

void loop()
{
myservo.writeMicroseconds (1500);
delay (1000);

myservo.writeMicroseconds (1000);
delay (1000);

myservo.writeMicroseconds (2000);
delay(1000);

}

So, what does that program actually do and what do you want it to do that is different?

And please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

…R