Servo Motor SG90
Wiring
| Servo Wire | Arduino Pin |
|---|---|
| Brown (GND) | GND |
| Red (VCC) | 5V |
| Orange (Signal) | D9 (~PWM) |
Code
#include <Servo.h>
Servo myservo;
void setup() { myservo.attach(9); }
void loop() {
myservo.write(0); delay(1000); // 0 degrees
myservo.write(90); delay(1000); // 90 degrees
myservo.write(180); delay(1000); // 180 degrees
}
Specifications
- SG90: 1.2 kg·cm, 0.12s/60°
- MG996R: 10 kg·cm, 0.17s/60°
- PWM: 50 Hz, pulse 500-2400 µs
Power the servo externally
Servos draw 500mA-2A at stall. Arduino 5V pin can only supply ~400mA. Use a separate 5V power supply for servos, with common GND to Arduino.