Thursday, March 13, 2025

Beginner's Guide: Using SG90 and MG90 Servo Motors with Arduino

In our latest tutorial, we delve into the world of servo motors, focusing on the SG90 and MG90 models, and demonstrate how to control them using an Arduino board. This guide is perfect for beginners and electronics enthusiasts eager to enhance their projects with precise motor control.

SG90 and MG90 servo motors with Arduino

Understanding Servo Motors

Servo motors are essential components in robotics and automation, offering precise control over angular or linear positions. The SG90 and MG90S are popular micro servo motors, each with unique characteristics.
Specification of servo motors SG90 and MG90S

Step-by-Step Instructions

Step 1: Components Required
To follow along with the tutorial, you'll need:
Components required for this tutorial
✅ Arduino UNO board
✅ SG90 or MG90 servo motor
✅ Jumper Wires
✅ USB cable for Arduino

Step 2: Setting Up the Circuit
Connecting the servo motor to the Arduino is straightforward:
Connection servo motor

Connection between servo motor and Arduino

Brown Wire: Connects to GND on the Arduino
Red Wire: Connects to the 5V pin
Orange/Yellow Wire: Connects to a PWM-capable digital pin 9

Step 3: Programming the Arduino
Using the Arduino IDE, you can write a simple program to control the servo motor or you can download the code HERE.
#include <Servo.h>

Servo myServo;

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

void loop() {
  myServo.write(0);   // Move servo to 0 degrees
  delay(1000);        // Wait 1 second
  myServo.write(90);  // Move servo to 90 degrees
  delay(1000);        // Wait 1 second
  myServo.write(180); // Move servo to 180 degrees
  delay(1000);        // Wait 1 second
}

Open Arduino IDE and copy-paste the code
Step 4: Expected Output
After uploading the code to your Arduino, observe the servo motor as it moves through the specified angles. If the servo doesn't respond as expected, double-check your wiring and ensure the motor receives adequate power.
Servo motor SG90 at 0°

Servo motor SG90 at 180°

Servo motor MG90S at 0°

Servo motor MG90S at 180°

Conclusion
By following this tutorial, you've learned how to control SG90 and MG90 servo motors using simple Arduino code. This foundational skill opens up possibilities for more complex projects involving precise motor control. For a visual walkthrough and additional insights, watch our full tutorial below:

Video


🔔 If you found this guide helpful, share it with fellow makers! For more tutorials, subscribe to our YouTube channel and follow us on social media. 🚀

No comments:

Post a Comment