Home Industry InsightBLDC
Looking for a suitable motor? Looking for a suitable motor?
Looking for a suitable motor?

Mastering Micro Servo SG90 with Arduino: A Beginner’s Guide to Creative Robotics

小编

Published2025-10-15

part 1:

Unlocking the Potential of the Micro Servo SG90 with Arduino

In the ever-expanding universe of DIY electronics and robotics, micro servos like the SG90 have become beloved tools for hobbyists and seasoned engineers alike. Their compact size, affordability, and versatility make them perfect for tasks ranging from simple robotic arms to complex drone stabilization systems. If you've recently started exploring Arduino-based projects or are contemplating your first servo experiment, understanding how to effectively control the SG90 with Arduino opens up a world of possibilities.

What Makes the SG90 Micro Servo Special?

Before jumping into the coding and circuitry, it’s helpful to appreciate what makes the SG90 stand out. This mini servo is known for its lightweight yet durable design, with a torque of about 1.8 kg·cm and a rotation range of roughly 180 degrees—ideal for small-scale projects where space and power are constraints.

It operates with a standard control signal, typically a PWM (Pulse Width Modulation) signal, which tells the servo where to position its arm within the rotational range. This simplicity in control allows for precise movements with minimal hardware.

Getting Started: Tools and Components Needed

To embark on your SG90 automation journey, gather the following:

Arduino Uno or compatible board: The brain of your operation. SG90 Micro Servo: The actuator that moves. Jumper wires: For connections. Breadboard: Optional, for prototyping. External Power Supply: Particularly if controlling multiple servos simultaneously, to prevent overloading the Arduino's onboard power. USB cable: To connect Arduino to your computer. Arduino IDE: Free software for programming your microcontroller.

Circuit Setup: Connecting the SG90 to Arduino

Power: Connect the servo's red wire to the 5V output on the Arduino (or an external power supply if multiple servos are used). Connect the black or brown wire to GND. Control Signal: Connect the orange or yellow signal wire to a PWM-capable digital pin on the Arduino, often pin 9. Ground: Ensure the Arduino GND and the servo GND are common.

Here's a quick schematic overview:

[Arduino 5V] ----> [Servo Vcc (Red)] [Arduino GND] ----> [Servo GND (Black/Brown)] [Digital Pin 9] ----> [Servo Signal (Yellow/Orange)]

With the hardware ready, it's time to write the code that brings your servo to life.

Basic Arduino Code to Control SG90

Start simple: make your servo move to a specific position, then sweep back and forth. The Servo library in Arduino is your friend here.

#include Servo myServo; // create servo object void setup() { myServo.attach(9); // attach servo to pin 9 } void loop() { // Move servo from 0 to 180 degrees for (int position = 0; position <= 180; position += 1) { myServo.write(position); delay(15); // waits 15ms for the servo to reach the position } // Move servo from 180 to 0 degrees for (int position = 180; position >= 0; position -= 1) { myServo.write(position); delay(15); } }

This basic script will make the servo oscillate smoothly between 0° and 180°, giving you a simple yet effective starting point.

(To be delivered in the next message)

Leveraging innovations in modular drive technology, Kpower integrates high-performance motors, precision reducers, and multi-protocol control systems to provide efficient and customized smart drive system solutions.

Update:2025-10-15

Contact a motor expert for product recommendation.
Contact a motor expert for product recommendation.

Powering The Future

Contact Kpower's product specialist to recommend suitable motor or gearbox for your product.