Servo SG-90 BUG!

#include<Servo.h>

Servo motor1;
void setup() {
motor1.attach(22);

}

void loop() {
motor1.write(90);
delay(3000);
motor1.write(180);
}

This is my code for Servo Motor

Firstly I set the Servo to 0 degree position.
When I run the code it is turning 90 but after 3s. it is not turning to 180 degree position

I change the degree many times but I can't make the servo turn 2 times in that code
How can I change it

SERVO SG-90 5V Arduino MEGA 2560

You set the Servo to 180 degrees then a few microseconds later, loop() repeats, setting the Servo to 90 degrees. Add a delay() after the write 180.

groundFungus:
You set the Servo to 180 degrees then a few microseconds later, loop() repeats, setting the Servo to 90 degrees. Add a delay() after the write 180.

That's right. I forgot it. Now it's okey. Thanks :slight_smile: