Flickering LED when servo moves I just got to play around with Arduino lately so I'm really new on this stuff and sorry for the grammar error.

I got a work where I need to turn the LED on all the time, my plan is to add a slow fade in and fade out later but the problem occurs when I add the servo.

Everytime servo starts moving slowly or fast the LED kinda flickering/dim like it lost power and come back to normal after the servo stops moving.

Here's the scheme I used and the code, I only change some delay to 5ms and so to test it out but no matter what the led is keep flickering.

Im using nano v.3 clone if its matter.



#include &lt;Servo.h&gt;
Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 100;    // variable to store the servo position
int ledpin3 = 3;

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  pinMode(ledpin3, OUTPUT);
}

void loop() {
  digitalWrite(ledpin3, HIGH);
  delay(1000);

  for (pos = 99; pos &lt;= 150; pos += 1) { // 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
  }

  for (pos = 150; pos &gt;= 30; pos -= 1) { // 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
  }

  for (pos = 30; pos &lt;= 99; pos += 1) { // 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
  }
}
If you are powering the arduino via usb try not to do that or plug it in to an usb 3.0 (and higher) port. The reason for this is that the servo draws a lot of power and the standard usb 2.0 with 0.5A can't handle the load and you got an voltage drop. And in that period of time the led goes off. usb 3.0 (and higher) can handle up to 1.5A so this souldn't be an error.