RoboThings

servo_360
The MG995 is a high-torque 360° servo motor widely used in robotics and mechanical projects. In this tutorial, we’ll show you how to control an MG995 360° servo motor with an Arduino Nano step by step.

What You’ll Need

  • Arduino Nano
  • MG995 360° servo motor
  • 10µF capacitor (optional, for voltage stabilization)
  • External power source (5-6V) for the servo motor
  • Jumper wires
  • Breadboard

Step 1: Install the Arduino IDE

If you haven’t already, download and install the Arduino IDE from the official Arduino website.

Step 2: Pin Configuration for MG995

  • The MG995 servo has three pins:

    1. Red (VCC): Connect to the positive terminal of the power supply (5-6V).
    2. Brown (GND): Connect to the ground of both the power supply and the Arduino Nano.
    3. Orange (Signal): Connect to a PWM-capable pin on the Arduino Nano (e.g., D9).

Step 3: Circuit Diagram

Connect the components as shown below:

  1. Power Supply:

    • Connect the servo’s VCC (Red) to the positive terminal of the external power supply.
    • Connect the servo’s GND (Brown) to the GND of the Arduino and the power supply.
  2. Signal Pin:

    • Connect the servo’s Signal (Orange) pin to the Arduino Nano’s D9 pin.
  3. Optional Capacitor:

    • Place a 10µF capacitor between the servo’s VCC and GND for voltage stabilization.
 

Important: Do not power the servo directly from the Arduino Nano, as the servo motor may draw more current than the Nano can provide, potentially damaging your board.

Step 4: Arduino Code

Upload the following code to your Arduino Nano:

				
					#include <Servo.h>

Servo myServo; // Create a servo object

void setup() {
  myServo.attach(9); // Attach the servo to pin D9
}

void loop() {
  // Rotate clockwise
  myServo.write(0); // Send 0° signal
  delay(2000);      // Wait for 2 seconds

  // Stop the servo
  myServo.write(90); // Send 90° signal (neutral position)
  delay(2000);       // Wait for 2 seconds

  // Rotate counterclockwise
  myServo.write(180); // Send 180° signal
  delay(2000);        // Wait for 2 seconds
}

				
			

Step 5: How It Works

 

    1. The Servo.h library simplifies controlling the servo.
    2. The write() function is used to control the servo’s direction:
      • : Full clockwise rotation.
      • 90°: Stop (neutral position).
      • 180°: Full counterclockwise rotation.
    3. The delay functions allow time for the servo to move before changing its direction.

Testing Your Setup

  • Power up your Arduino Nano.
  • Observe the MG995:
    • It should rotate clockwise for 2 seconds, stop for 2 seconds, and then rotate counterclockwise for 2 seconds in a loop.

Troubleshooting

  1. Servo Not Moving:
    • Check the wiring and ensure the power supply is sufficient.
  2. Jerky Movement:
    • Add a capacitor for voltage stabilization.
  3. Arduino Resetting:
    • Ensure the servo is not powered directly from the Arduino Nano.

Applications of MG995 360° Servo

  • Robot wheels or turrets
  • Pan-tilt systems
  • Conveyor belts
  • Automated steering systems

With this tutorial, you are now ready to integrate the MG995 360° servo motor into your projects. If you have questions or face issues, feel free to leave a comment below!

3 5 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
Open chat
1
Hi, how can I help you?
Powered by