小编
Published2025-10-15
Unveiling the Wonder of the SG90 Servo Motor and Arduino
In the vibrant world of hobby electronics and robotics, few components have captured the imaginations of tinkerers, students, and professionals alike quite like the SG90 servo motor. It's small but mighty—a compact marvel that can rotate, tilt, and precisely position objects, opening up a universe of creative possibilities. When paired with the versatile Arduino microcontroller, it transforms from a simple component into a powerhouse of automation and motion.
The SG90 servo motor is renowned for its affordability, reliability, and ease of use. Measuring roughly 22.8mm x 12.2mm x 28.5mm, it fits comfortably into tight spaces, making it ideal for projects where size is a concern. Despite its tiny stature, it can typically deliver about 1.8 kg/cm of torque at 4.8V, enough to move light loads or perform precise position adjustments.
One of its most attractive qualities is its simplicity. The SG90 is a standard RC servo with a three-wire interface: power (usually 5V), ground, and a control signal. This straightforward setup makes it accessible for beginners while still providing enough precision for more advanced iterations.
Connecting the Dots: Arduino & SG90
The magic begins when you connect the SG90 to an Arduino board. The Arduino, a microcontroller renowned for its user-friendly nature, acts as the brain. It sends PWM (Pulse Width Modulation) signals to the servo, instructing it to turn to a specific angle.
Imagine you want to create a robotic arm, a pan-and-tilt camera, or even a simple animated sculpture. Using the Arduino’s programming environment, you can specify exact positions for the servo, query sensors to determine movement conditions, or even create complex sequences—all controlled effortlessly by code.
Getting Started: Essential Components
Before diving into code, make sure you have the essentials:
Arduino Uno or compatible microcontroller board SG90 servo motor Power supply (preferably a 4.8V to 6V source—most likely via the Arduino's 5V pin) Jumper wires Breadboard (optional but helpful for organizing connections)
Wiring the SG90 to Arduino
Connecting the SG90 is straightforward:
Red wire (Vcc) connects to 5V on Arduino Black or brown wire (Ground) connects to GND Orange, yellow, or white wire (Signal) connects to a PWM-capable digital pin, typically pin 9 or 10
Remember, if your project involves multiple servos or demands higher power, consider powering them from an external power source and common ground to prevent draw issues.
First Movement: Making the Servo Spin
Here's where your journey begins. The simplest code to move your SG90 servo motor from 0° to 180° looks like this:
#include Servo myServo; void setup() { myServo.attach(9); // attaches the servo on pin 9 } void loop() { myServo.write(0); // move to 0 degrees delay(1000); // wait 1 second myServo.write(180); // move to 180 degrees delay(1000); // wait 1 second }
Upload this sketch to your Arduino, and watch the servo sweep back and forth. That simple code demonstrates how intuitive controlling the SG90 with Arduino can be.
Understanding PWM and Servo Control
The core of servo control is PWM. Unlike digital signals that are just ON or OFF, PWM varies the duration of the ON pulse within a fixed period. For continuous rotation servo motors like the SG90, or standard positional ones, this pulse width (typically between 1 ms to 2 ms) determines the position.
1 ms pulse (~5% duty cycle): rotates to 0° 1.5 ms pulse (~7.5%): centers at 90° 2 ms pulse (~10%): rotates to 180°
The Arduino's Servo library simplifies this by abstracting away the raw PWM signal, allowing you to specify target angles directly.
Expanding Your Creativity
Once you're comfortable with basic movements, you can start exploring:
Sequential motions: creating movements that follow a specific order Sensor feedback: integrating proximity, light, or touch sensors to make your servo respond intelligently Multiple servos: orchestrating complex mechanical systems—like multi-jointed arms or panning cameras Remote control: adding Bluetooth or Wi-Fi modules to manipulate your servos wirelessly
The capabilities of the SG90 and Arduino combo make it a favorite for projects such as:
Robotic arms for pick-and-place tasks Camera pan-and-tilt systems for photography or surveillance Automated curtains or blinds Animatronics figures for art installations Educational kits for teaching principles of robotics and control systems
Stay tuned for Part 2, where we delve deeper into advanced programming techniques, troubleshooting, and innovative project ideas using the SG90 servo motor and Arduino.
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 Kpower's product specialist to recommend suitable motor or gearbox for your product.