Servo Motor with an External Power

Servo, can be powered by another power source without Arduino power. Only thing important here is that all the GND are connected to each other.

Like this you can add as many servo motors as you want.

***Important! If you will use high voltage battery and you want give power to arduino with same power source, you need to put a 7805 voltage regulator in, and make a parallel circuit for that too.

Hardware Required :

Arduino or Genuino Board
Servo Motor
Battery for Servo (I used for my servo; four pcs (1.5V) batteries.)
Mini Breadboard

Recommended site to buy the required hardware:

Get the Code :
#include <Servo.h>

Servo name_servo;

int servo_position = 0;

void setup() {

  name_servo.attach (9);


void loop() {

  for (servo_position = 0; servo_position <=180; servo_position +=1){


  for (servo_position=180; servo_position >= 0; servo_position -=1){