do you think my Nano has defecet?

i am working on arduino Nano and using simple sweeping code which is as below.
while servo sweeps some times then it stops and built-in LED " L " start blinking 4-5 sec after then servo starts sweeping again. this circumstance goes to loop.
I don`t see any reason in the code the Nano being delay randomly.
do you think the nano has defecet?

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // twelve servo objects can be created on most boards
 
int pos = 0;    // variable to store the servo position  
void setup() 
{ 
  myservo.attach(8);  // attaches the servo on pin 9 to the servo object 
} 
 
void loop() 
{ 
 
  myservo.write(0);              // tell servo to go to position in variable 'pos' 
    delay(1500);       
  myservo.write(180);              // tell servo to go to position in variable 'pos' 
    delay(1500);
}

Put a capacitor between power and ground of the servo.

Dollars to donuts, the servo is causing momentary voltage drops that are enough to reset the board, which then runs the bootloader (blinking the LED), before running the sketch again.

Delta_G:
How are you powering the servo?

i have been powering by usb

DrAzzy:
Put a capacitor between power and ground of the servo.

Dollars to donuts, the servo is causing momentary voltage drops that are enough to reset the board, which then runs the bootloader (blinking the LED), before running the sketch again.

what would be value of capacitor?

Regards

Delta_G:
So the servo power is coming off the Arduino board? That may well be the problem. A servo should usually have its own power supply. If it pulls too much current then the board doesn't get full power and it resets.

thanks for your quick respond. i am gonna try with external power and let you know the result
Regards