Serial Monitor and Servo Problem

Hi,
Here is the code that I am using to control a servo and using serial monitor to debug a variable-

#include <Servo.h>

Servo servo;
int angle = 10;

void setup() 
{
  Serial.begin(9600);
  Serial.println("Ready!");
  delay(1000);
  
  servo.attach(8);
  servo.write(angle);
}


void loop() 
{ 
 // scan from 0 to 180 degrees
  for(; angle < 140; angle++)  
  {                                  
    servo.write(angle);               
    delay(5);                   
  } 

  Serial.println(angle);
  delay(1000);
  
  // now scan back from 180 to 0 degrees
  for(; angle > 20; angle--)    
  {                                
    servo.write(angle);           
    delay(30);       
  } 

  Serial.println(angle);
  delay(1000);
}

It works ok, untill I attach the signal pin of servo in the arduino. I am using a sg90 servo directly attach to Arduino. When I don't attach the signal pin the serial monitor works ok. It prints the angle variable as it should. But as soon as I attach the signal pin serial monitor stops printing the angle variable. I am a bit confused. Can someone clarify what I am doing wrong.
Thanks in advance

When the servo moves it probably pulls more current than the Arduino is comfortable with. The servo should have its own power supply. It shouldn't attach directly to the Arduino. Only the control wire.

Ok, that's what I also thought. I don't have battery with me right now that's why I could not test it. Thanks for the reply.

For you, and others, invest in a USB to 2.5mm power adapter (or make one). You can then plug that in the power jack of the Arduino and take power off the Vin pin, bypassing the chip internals.

Only the control wire.

And ground.

I just tested it with external servo battery and its working fine now. Thank you for your reply and help.