Source: https://mokxi.com/parts/servo
Updated: 2026-09-27

Part

# Hobby servo

A pulse width, not a duty cycle. The horn turns to wherever you send it.

or see every part

- 3 pins
- 6 properties

Drawn live by the editor's own code, at the size you see it.

Reference

## Every one of its 3 pins

Pin

Role

What it does

GND

Input or output

Ground, brown wire.

VCC

Input or output

Supply, red wire.

PWM

Input

Signal, orange wire: a pulse width, not a duty cycle.

This part

## What it does

A hobby servo, SG90 style, turns its horn to an angle and holds it. Its signal wire does not take PWM in the dimming sense: the servo measures the width of each pulse, about 1 millisecond for one end of its travel and 2 for the other, sent roughly fifty times a second. That is why analogWrite() on an Uno cannot drive one and the Servo library makes the pulse itself. Mokxi’s part times each pulse off the pin’s own edges and walks the horn towards the angle at the datasheet’s 0.1 seconds per sixty degrees, ignores a width outside its window as noise, and holds its position when the pulses stop. The window, the travel and the speed are all properties. What it does not model is current: a real SG90 can pull enough when it stalls to reset the board powering it, and nothing here will warn you about that.

How to use it

## How to use a servo with an Arduino

Brown to GND, red to 5 V, orange to any digital pin. Then use the Servo library: attach() the pin once in setup() and write() an angle from 0 to 180 whenever you want the horn to move. The library’s calls compile here as they stand; its default pulse window is the SG90’s 1000 to 2000 microseconds, and attach(pin, 544, 2400) gives the upstream library’s.

On a real bench, give a servo its own 5 V supply once it is carrying any load, and join the grounds.

Part pin

Board pin

GND (brown)

GND

VCC (red)

5 V

PWM (orange)

Pin 9

ESP32Servo.h is the same class under the name ESP32 tutorials use, and the ESP32-C3 servo example drives one from a hardware PWM channel.

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

The Servo library sweep, as it compiles here

Reference

## The 6 properties you can set

Property

Default

What it means

min_pulse

1000

the pulse widths for the two ends of travel, 1000 and
2000 microseconds by default.

max_pulse

2000

the pulse widths for the two ends of travel, 1000 and
2000 microseconds by default.

range

180

degrees of travel, 180 by default.

speed

600

how fast the horn moves towards a new angle, 600 degrees per second.

mode

positional (or continuous)

rpm

110

How it is modeled

## What is true about the Hobby servo, here

### What is modeled

The part is a stopwatch on one pin and a horn that walks towards the angle the
stopwatch names: a rising edge starts the clock, a falling edge stops it, a width
outside the min_pulse–max_pulse window is treated as noise and ignored, and with
no pulses at all the horn stays exactly where it is, the way a real servo does when
its signal wire falls off. speed matches the datasheet's 0.1 seconds per sixty
degrees. A servo that only sweeps 120 degrees, or one that wants the Arduino
library's default 544–2400 us window, is those three numbers changed and nothing
else.

### Not modeled

Current. A real SG90 pulls a quarter of an amp when it stalls and can brown out the
board driving it (the single most common reason a servo project misbehaves on the
bench), but Mokxi's supply rails have no impedance to sag, so a sag here would be a
lie about something that cannot happen in this simulator. VCC/GND are read for
one thing only: below 4 V the servo does not move at all.

No torque, no load and no overshoot. The horn walks to its target at a constant
600 degrees a second and stops dead. There is no acceleration, no settling, no
hunting around the target, no dead band (a real SG90 ignores changes under about
5 microseconds of pulse width) and no gear backlash, so a commanded angle is always
reached exactly. The 0.1 seconds per sixty degrees is the datasheet's unloaded figure
and applies here whatever is on the horn, because there is nothing on the horn.

The stopwatch is also more forgiving than a real servo's: the horn is updated every
20 ms whatever the pulse rate is, a pulse longer than 3 ms is discarded rather than
treated as a fault, and a gap in the pulse train is simply held rather than released.

From Servo (hobby, SG90 style), in full.

Projects

## See the Hobby servo in a project

Shown here on: Arduino Uno R3

Learn

## Where it turns up in a lesson

### In a learn article

- Arduino Servo Motor with a Potentiometer

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio, no real internet), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

STM32F411 Black Pill

The Black Pill on our own Cortex-M4 core. Pick a program and press Run.

BBC micro:bit V2

The nRF52833 board with its 5x5 LED matrix, buttons A and B and a speaker. Wire the rings to a breadboard.

See every part

## Wire up the Hobby servo

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building Open the editor
