Ordered on weekdays before 14:00 = shipped the same day and delivered the next day in 98% of cases. Free returns 30-day reflection period 1-year warranty

Wiring diagram and code example

How to connect the Servo SG90 Micro 180 degrees to an Arduino UNO or ESP32, with an example sketch you can upload straight away.

SG90 Micro Servo Sweep Demo

This project demonstrates how to control an SG90 micro servo using an Arduino Uno. The sketch sweeps the servo arm smoothly back and forth from 0 to 180 degrees. Open the Serial Monitor at 115200 baud to observe the current servo angle.

Wiring diagram: Servo SG90 Micro 180 degrees on an Arduino UNO
Wiring diagram · Click to enlarge
Connection table: Servo SG90 Micro 180 degrees on an Arduino UNO
Connection table · Click to enlarge
SG90_Micro_Servo_Sweep_Demo.ino · compiled and verified
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : SG90 Micro Servo Sweep Demo
 *  Board     : Arduino UNO (arduino:avr:uno)
 *  Parts     : Servo SG90
 *  Libraries : none (built-in)
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <Servo.h>

const int SERVO_PIN = 9;
Servo myServo;

void setup() {
  Serial.begin(115200);
  myServo.attach(SERVO_PIN);
  Serial.println(F("SG90 Servo Sweep Demo Started"));
}

void loop() {
  // Sweep from 0 to 180 degrees
  for (int pos = 0; pos <= 180; pos += 1) {
    myServo.write(pos);
    delay(15);
  }
  Serial.println(F("Reached 180 degrees"));
  delay(500);

  // Sweep back from 180 to 0 degrees
  for (int pos = 180; pos >= 0; pos -= 1) {
    myServo.write(pos);
    delay(15);
  }
  Serial.println(F("Reached 0 degrees"));
  delay(500);
}

Wiring diagram and example code generated by Codey.online — https://www.codey.online

SG90 Servo Sweep with ESP32

This project sweeps an SG90 micro servo back and forth across 180 degrees. The servo is powered from the ESP32 VIN pin (5V from USB) and controlled using a PWM signal generated with the ESP32Servo library. Open the Serial Monitor to observe the current angle as it sweeps.

Wiring diagram: Servo SG90 Micro 180 degrees on an ESP32 DevKit V1
Wiring diagram · Click to enlarge
Connection table: Servo SG90 Micro 180 degrees on an ESP32 DevKit V1
Connection table · Click to enlarge
SG90_Servo_Sweep_with_ESP32.ino · compiled and verified
/*
 * ==================================================================
 *  Generated by Codey.online  —  https://www.codey.online
 * ==================================================================
 *  Project   : SG90 Servo Sweep with ESP32
 *  Board     : ESP32 DEVKIT V1 (esp32:esp32:esp32doit-devkit-v1)
 *  Parts     : Servo SG90
 *  Libraries : ESP32Servo 3.1.3
 *
 *  Codey Online is an AI-powered browser IDE for Arduino and ESP32.
 *  Describe your project and Codey writes the code, draws the wiring
 *  diagram and uploads it to your board, straight from the browser.
 *  This code is free to use, modify and share, without warranty.
 * ==================================================================
 */

#include <ESP32Servo.h>

const int SERVO_PIN = 18;  // GPIO 18 connected to servo PWM pin

Servo myServo;

void setup() {
  Serial.begin(115200);
  Serial.println("ESP32 SG90 Servo Sweep Demo");

  // Allow allocation of all timers for ESP32Servo
  ESP32PWM::allocateTimer(0);
  ESP32PWM::allocateTimer(1);
  ESP32PWM::allocateTimer(2);
  ESP32PWM::allocateTimer(3);
  myServo.setPeriodHertz(50);      // Standard 50 Hz servo
  myServo.attach(SERVO_PIN, 500, 2400); // Standard pulse width limits for SG90
}

void loop() {
  // Sweep from 0 to 180 degrees
  for (int pos = 0; pos <= 180; pos += 5) {
    myServo.write(pos);
    Serial.print("Position: ");
    Serial.println(pos);
    delay(20);
  }

  delay(500);

  // Sweep back from 180 to 0 degrees
  for (int pos = 180; pos >= 0; pos -= 5) {
    myServo.write(pos);
    Serial.print("Position: ");
    Serial.println(pos);
    delay(20);
  }

  delay(500);
}

Required libraries: ESP32Servo 3.1.3

Wiring diagram and example code generated by Codey.online — https://www.codey.online

Servo SG90 Micro 180 degrees

The SG90 Micro Servo is a high-quality, small servo that is perfect for use in hobby projects and small robots. With a compact size of just 23 x 12.2 x 29 mm and a weight of only 9 grams, this servo is ideal for use in small spaces where other servos do not fit.

View the SG90 wiring diagram and example code for Arduino.

The SG90 Micro Servo has a torque of 1.5 kg/cm and can be connected to a voltage of 4.8-6V. It is also equipped with a 3-pin connector, making it easy to connect to your microcontroller or development board.

This servo has a rotation range of 180 degrees and can be positioned accurately at any angle between 0 and 180 degrees. It also has a fast response time of just 0.1 seconds, making it ideal for applications where speed is important.

  • Power: 1.8 kg/cm
  • Rotation range: approx. 180 degrees
  • Operating voltage: 4.8V-6V
  • Speed: 0.10 sec / 60 degrees
  • Dimensions: approx. 22.2 x 11.8 x 31 mm
  • PWM frequency: 50hz (20ms)
  • Weight: 9g
  • No-load speed: 0.12 sec / 60 degrees (4.8 V)
  • Torque: 1.5-1.7 kg/cm (4.8V-6V)
  • Operating temperature: -30 / + 60 degrees Celsius

 

 

  • Compact size
  • 180 degrees
  • 9 grams
  • 3-pin connector
Playing loads the video from YouTube.

Why choose this product?

  • Compact size – Fits in small spaces.
  • For small robots – Suitable for hobby projects and small robots.
  • Precise positioning – Positionable between 0 and 180 degrees.
  • Fast response time – Only 0.1 seconds response time.
  • Easy to connect – 3-pin connector for microcontroller or development board.
Specifications
Dimensionsapprox. 22.2 x 11.8 x 31 mm
Connection3-pin connector
Weight9g
Operating voltage4.8V-6V
Suitable forArduino
Operating temperature-30 / + 60 degrees Celsius
Speed0.10 sec / 60 degrees
Maximum force1.8 kg/cm
PWM Frequency50hz (20ms)
Torque1.5-1.7 kg/cm (4.8V-6V)
Rotation rangeapprox. 180 degrees
No-load speed0.12 sec / 60 degrees (4.8 V)

Frequently bought together

Total: € 17,53

Reviews

★★★★★ 5,0/5 4 reviews
  • ★★★★★Wiel ZeegersVerified purchase

    Great products

  • ★★★★★Gijs HardieckVerified purchase

    works well

  • ★★★★★ArnoVerified purchase

    Great 9g servo for a low price.

Write a review
Your rating

Shipping & returns

Shipping

  • Parcel with track & trace€ 7,70Within 24 hours
  • Pick up at PostNL location€ 7,40Within 24 hours
  • Letterbox parcel€ 3,70Within 2 business days
  • Letterbox parcel 24 hours€ 4,55Within 24 hours
  • Pick up in storeFree
All about shipping

Returns

Not satisfied? You have 30 days after delivery to return the product.

All about returns

Recently viewed