The project describes how to control one or two servo motors using Arduino.

Summery

The project describes how to control one or two servo motors using Arduino.

About Project

If we attach all the Servos to Arduino supply pins then do not work in a proper way due to the absence of sufficient current to drive all the motors.So we need to utilize a separate power supply for the motors, either it is from some adapters (5v 2A) or from 9v batteries.

Basically, a servo motor is an integration of DC motor, position control system, gears. Servo motors are accessible in various shapes and sizes. A servo motor will have generally 3 wires, one is for positive voltage second is for ground and the last one is for position setting.

For External Power supply we can utilize Adapters, RPS (Regulated Power Supply Instrument), or 9v batteries. Or else we can also utilize a laptop USB port to power the servo. For this, we just need to short the Arduino ground to external supply ground.

Utilize the Arduino code, which is given below to program your Arduino.

hIoTron IoT Course will give you a thorough hands-on knowledge of IoT Solutions.


servo_motor_LEk3aZ6r1j.jpg
        #include <Servo.h>

Servo servo1; 
Servo servo2;
Servo servo3;
Servo servo4;

int i = 0;

void setup() {
  servo1.attach(3);
  servo2.attach(5); 
  servo3.attach(6); 
  servo4.attach(9); 
}

void loop() {
  for (i = 0; i < 180; i++) { 
    servo1.write(i);              
    servo2.write(i);     
    servo3.write(i);
    servo4.write(i);         
    delay(10);                      
  }
  for (i = 180; i > 0; i--) { 
    servo1.write(i);                
    servo2.write(i);     
    servo3.write(i);
    servo4.write(i);          
    delay(10);                      
  }

}
    
rasika Joshi
hIoTron offers an End-to-End IoT Training with live use cases using IoT hardware kit.