Servo Motor Control

Z2M Parts: MMD-00002-A, MMD-00002-B

Control a servo motor to rotate to specific angles using PWM signals.

Circuit Diagram
Circuit diagram for Servo Motor Control
Wire Connections & Pin Configuration

Wire Color Connections:

Orange/Yellow → Digital Pin 9 to Servo signal
Red → 5V to Servo power
Black/Brown → GND to Servo ground

Pin Configuration:

Arduino Digital Pin 9 → Servo signal (orange/yellow)
Arduino 5V → Servo power (red)
Arduino GND → Servo ground (brown/black)
Arduino Code
Edit
#include <Servo.h>

Servo myservo;
int ang;

void setup() {
  myservo.attach(9);
}

void loop() {
  for (ang = 0; ang <= 180; ang += 1) {
    myservo.write(ang);
    delay(15);
  }
  for (ang = 180; ang >= 0; ang -= 1) {
    myservo.write(ang);
    delay(15);
  }
}

Instruction Details

Wiring: Connect servo signal wire (orange/yellow) to Digital Pin 9, power (red) to 5V, ground (brown/black) to GND. For high-torque servos, use external 5–6V supply.
Library: Not required (built-in Servo library).
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: Servo motor will sweep from 0° to 180° and back continuously.

How to Use

  1. Connect the required components as per the Pin Configuration above
  2. Open Arduino IDE and create a new sketch
  3. Copy and paste the code above
  4. Select your Arduino board and COM port from Tools menu
  5. Click the Upload button to upload the code to your Arduino
  6. Open Serial Monitor (if applicable) to see the output

Components Required

  • Arduino Uno
  • Servo Motor (SG90)
  • Breadboard
  • Jumper Wires
  • External 5–6V Power Supply (optional, for high-torque)

Category: Motors & Servos