AI agents & screen readers: for a machine-readable, text-only catalogue, start at /llms.txt. Products are available as Markdown (/products.md, /products/{handle}.md) and JSON (/products.json, /products/{handle}.json).
Store
Control a servo with distance
Beginner 35 minutes

An interactive 3D build with a live HTML servo controller and Arduino code.

Build a distance-controlled continuous rotation servo with the Little Bird Uno and a full-size breadboard. Move a flat object towards the sensor to slow and stop the servo.

This demonstration uses USB power through the Uno’s 5V pin. Keep the small servo unloaded and its horn clear. Disconnect USB before changing wires. If the Uno resets or the servo struggles, unplug USB and stop the test.

View Markdown

Step 1 — Watch the complete build

Press Play for the narrated build. Drag the view to explore in 3D, or follow the individual steps below.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

We’re making a distance-controlled servo. Move an object closer to slow it down, or further away to speed it up. This unloaded demonstration uses U S B power through the Uno. Leave U S B disconnected while wiring. Connect five volts from the Uno to the upper positive rail, and ground to the upper negative rail. These shared connections will supply both the sensor and the servo. This ultrasonic sensor measures distance using its two silver transducers. Face them towards the object you want to detect, with the four header pins accessible for the jumper wires. Connect the sensor’s power pin to the upper positive rail, then its ground pin to the upper negative rail. Red carries five volts; black provides the return to ground. Connect digital pin seven to trigger, then digital pin six to echo. The Uno sends a brief trigger pulse and times the returning echo to work out the distance. This servo turns continuously. Our program controls its speed and direction, rather than choosing an angle. Keep the horn clear so the motor can turn freely during this demonstration. Connect the servo’s red power lead to the upper positive rail. Connect its brown or black ground lead to the lower negative rail. The remaining lead carries the control signal. Join the upper and lower negative rails with a black jumper. That completes the servo’s return path to the Uno, so the sensor, servo and controller share the same ground. Connect digital pin nine to the servo’s signal lead. The Servo library sends timed pulses: around fifteen hundred microseconds stops the motor, while shorter or longer pulses change its speed and direction. Check the wiring, then connect U S B to the Uno and upload the program below. Keep the servo unloaded. If the board resets or the motor struggles, unplug U S B and stop the test. Choose distance sensor mode and hold Run. Bring an object closer to slow the servo; at fifteen centimetres it stops. Move away to speed up again. Release Run to stop the motor.

Step 2 — Meet the build

We’re making a distance-controlled servo. Move an object closer to slow it down, or further away to speed it up. This unloaded demonstration uses USB power through the Uno. Leave USB disconnected while wiring.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

We’re making a distance-controlled servo. Move an object closer to slow it down, or further away to speed it up. This unloaded demonstration uses U S B power through the Uno. Leave U S B disconnected while wiring.

Step 3 — Prepare the rails

Connect five volts from the Uno to the upper positive rail, and ground to the upper negative rail. These shared connections will supply both the sensor and the servo.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

Connect five volts from the Uno to the upper positive rail, and ground to the upper negative rail. These shared connections will supply both the sensor and the servo.

Step 4 — Add the distance sensor

This ultrasonic sensor measures distance using its two silver transducers. Face them towards the object you want to detect, with the four header pins accessible for the jumper wires.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

This ultrasonic sensor measures distance using its two silver transducers. Face them towards the object you want to detect, with the four header pins accessible for the jumper wires.

Step 5 — Power the sensor

Connect the sensor’s power pin to the upper positive rail, then its ground pin to the upper negative rail. Red carries five volts; black provides the return to ground.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

Connect the sensor’s power pin to the upper positive rail, then its ground pin to the upper negative rail. Red carries five volts; black provides the return to ground.

Step 6 — Connect trigger and echo

Connect digital pin seven to trigger, then digital pin six to echo. The Uno sends a brief trigger pulse and times the returning echo to work out the distance.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

Connect digital pin seven to trigger, then digital pin six to echo. The Uno sends a brief trigger pulse and times the returning echo to work out the distance.

Step 7 — Add the continuous servo

This servo turns continuously. Our program controls its speed and direction, rather than choosing an angle. Keep the horn clear so the motor can turn freely during this demonstration.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

This servo turns continuously. Our program controls its speed and direction, rather than choosing an angle. Keep the horn clear so the motor can turn freely during this demonstration.

Step 8 — Connect the servo cable

Connect the servo’s red power lead to the upper positive rail. Connect its brown or black ground lead to the lower negative rail. The remaining lead carries the control signal.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

Connect the servo’s red power lead to the upper positive rail. Connect its brown or black ground lead to the lower negative rail. The remaining lead carries the control signal.

Step 9 — Share a common ground

Join the upper and lower negative rails with a black jumper. That completes the servo’s return path to the Uno, so the sensor, servo and controller share the same ground.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

Join the upper and lower negative rails with a black jumper. That completes the servo’s return path to the Uno, so the sensor, servo and controller share the same ground.

Step 10 — Connect the control signal

Connect digital pin nine to the servo’s signal lead. The Servo library sends timed pulses: around fifteen hundred microseconds stops the motor, while shorter or longer pulses change its speed and direction.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

Connect digital pin nine to the servo’s signal lead. The Servo library sends timed pulses: around fifteen hundred microseconds stops the motor, while shorter or longer pulses change its speed and direction.

Step 11 — Connect USB and upload

Check the wiring, then connect USB to the Uno and upload the program below. Keep the servo unloaded. If the board resets or the motor struggles, unplug USB and stop the test.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

Check the wiring, then connect U S B to the Uno and upload the program below. Keep the servo unloaded. If the board resets or the motor struggles, unplug U S B and stop the test.

Step 12 — Upload the Arduino program

Keep the servo unloaded. Pair the Uno in Chrome or Edge, choose Arduino Uno, then Verify and Upload. The App HTML is already loaded under the App tab. After upload, wait for Ready before pressing Run.

The sketch starts stopped and uses 115200 baud. Without Run heartbeats it stops within one second. USB supplies this demonstration through the Uno’s 5V pin; all components share ground.

Control a servo with distanceOpen in English ↗

Step 13 — Control the servo with distance

The connection is shared with the code editor above. Set a modest speed and hold Run; release to stop. Negative values reverse the servo. Choose Distance sensor to slow down from 60 cm to 15 cm and stop at 15 cm or on a missing echo. If the horn creeps at zero, release Run, open Neutral calibration and adjust the neutral pulse in small increments before testing again. Power off before touching the horn or wiring.

Download the App HTML to reuse in English → App → Edit HTML. The on-screen horn follows commands; it is not position feedback.

Step 14 — Try distance control

Choose distance sensor mode and hold Run. Bring an object closer to slow the servo; at fifteen centimetres it stops. Move away to speed up again. Release Run to stop the motor.

Explore in 3D

Loading assembly…

0:00 / 0:00
Transcript

Choose distance sensor mode and hold Run. Bring an object closer to slow the servo; at fifteen centimetres it stops. Move away to speed up again. Release Run to stop the motor.

Step 15 — Plot the readings

View distance and commanded speed on the same shared serial connection. Click legend entries to hide channels you do not need. Distance is −1 when no valid echo is received. Hold Run in the App while experimenting; changing guide steps releases the control and stops the servo.

Parts List

Required Parts (6)

Uno R3 - Little Bird
Uno R3 - Little Bird

Controller; connect its USB only after wiring.

x1

$19.55

In stock
Full sized breadboard
Full sized breadboard

830 contacts; use the labelled rails.

x1

$11.95

In stock
Micro Servo 9g - Continuous
Micro Servo 9g - Continuous

Continuous rotation; speed and direction rather than an angle.

x1

$8.20

In stock
40 pin 15CM Jumper wire M/M
40 pin 15CM Jumper wire M/M

One pack; use six male-to-male jumpers.

x1

$5.10

In stock
Ultrasonic Distance Sensor HC-SR04
Ultrasonic Distance Sensor HC-SR04

Distance input on D7/D6.

x1

$4.05

In stock
40 pin 15CM Jumper wire M/F
40 pin 15CM Jumper wire M/F

One pack; use four female-to-male jumpers.

x1

$5.10

In stock

Optional Extras (1)

USB Cable A-B for Arduino Uno/Mega
USB Cable A-B for Arduino Uno/Mega

Additional USB data cable; use an existing one if available.

Optional

$2.00

Project Summary

7 parts total

Required parts $53.95
Optional extras +$2.00
Total (required) $53.95

Unavailable items will be skipped

Maddy, co-founder of Little Bird

Need help? We're here for you!

Hi, I'm Maddy. My team and I are ready to help with your order or any questions.