Skip to content

Commit 615414d

Browse files
Merge pull request #1586 from arduino/Hannes7eicher/Servo-Example-Fix
Update Servo Example
2 parents 1fdada2 + d185793 commit 615414d

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed
27.9 KB
Loading
118 KB
Loading
5.52 KB
Loading
Binary file not shown.

content/learn/04.electronics/05.servo-motors/servo-motors.md

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
title: 'Servo Motor Basics with Arduino'
3-
description: 'Learn how to connect and control servo motors with your Arduino board.'
2+
title: "Servo Motor Basics with Arduino"
3+
description: "Learn how to connect and control servo motors with your Arduino board."
44
tags: [Servo]
55
author: Arduino
66
---
77

88
The [Servo Library](https://www.arduino.cc/reference/en/libraries/servo/) is a great library for controlling servo motors. In this article, you will find two easy examples that can be used by any Arduino board.
99

10-
The first example controls the position of a RC (hobby) [servo motor](https://en.wikipedia.org/wiki/Servo_(radio_control)) with your Arduino and a potentiometer. The second example sweeps the shaft of a RC [servo motor](https://en.wikipedia.org/wiki/Servo_(radio_control)) back and forth across 180 degrees.
10+
The first example controls the position of an RC (hobby) [servo motor](<https://en.wikipedia.org/wiki/Servo_(radio_control)>) with your Arduino and a potentiometer. The second example sweeps the shaft of an RC servo motor back and forth across 180 degrees.
1111

1212
You can also visit the [Servo GitHub repository](https://github.com/arduino-libraries/Servo) to learn more about this library.
1313

@@ -17,26 +17,61 @@ You can also visit the [Servo GitHub repository](https://github.com/arduino-libr
1717
- Servo Motor
1818
- 10k ohm potentiometer
1919
- hook-up wires
20+
- capacitors
21+
- power supply
22+
23+
## Powering Servo Motors
24+
25+
Servo motors have different power requirements depending on their size and the workload they are experiencing. A common servo motor such as the [Feetech Mini Servo Motor](https://store.arduino.cc/products/feetech-mini-servo-motor-120-degrees-9g) requires between 4.8 - 6 V at 5 – 6 mA when idle. It doesn't take very much energy to stand still.
26+
27+
But as soon as the motor starts moving, it starts using more energy, and it gets that energy by pulling more current from the power source.
28+
29+
If it experiences heavier loads such as added weight or an object blocking its movement , it naturally needs to use even more energy to move the obstacle, and as a result the current consumption increases. The current consumption of the motor linked above can reach up to 800 mA.
30+
31+
This high current-draw is generally not safe to draw from an Arduino board. To avoid damaging our board we need to power the servo motor through an external power supply. Choosing the correct power supply depends on the servo motor you are using, so always check the specifications. Pay especially close attention to the:
32+
33+
- **operating voltage range**
34+
- **idle current** - consumption when **not** moving
35+
- **running current** - consumption when moving freely
36+
- **stall current** - consumption under max load or when blocked
37+
38+
To power a 4.8 - 6 V servo you could use a **5 V 1 A** AC Adapter, cut the cable, and connect the wires to the servo using e.g. a breadboard.
39+
40+
**_Note that USB wall chargers are limited to 500 mA (USB 2.0) or 900 mA (USB 3.0)._**
41+
42+
If your project needs to move around freely without being attached to a power outlet you can also choose batteries to power the servo. If you need 5 V exactly you can use two 18650 Li-Ion batteries together with a step-down converter.
43+
44+
A step-down converter is needed because 18650 Li-Ion batteries will give you around 7.4 V. The max current depends on the specific battery but most of them are designed to output above 1A which is enough to power our small servo.
45+
46+
**_If you are using bigger or more servos make sure to check your power requirements accordingly._**
47+
48+
**Capacitors** are recommended for powering servo motors. They help stabilize the power supply, minimize voltage drops, and reduce electrical noise. The specific capacitor values may vary based on the servo motor's requirements, but including them is good practice for better performance and reliability.
49+
50+
When using a [Feetech Mini Servo Motor](https://store.arduino.cc/products/feetech-mini-servo-motor-120-degrees-9g) we recommend using a **100 µF** capacitor.
51+
52+
![Capacitor](./assets/capacitor.png)
53+
54+
**_Because some capacitors are polarised (meaning that they have a direction), you may need to be careful with how you connect them to your circuit. Make sure to connect them correctly by checking for markings such as a white stripe, a '+' symbol, or a longer lead. If your capacitor has these, match the indicators of the capacitor with your circuit (pay attention to the + and - signs), and be careful not to exceed the voltage limits. This precaution helps prevent issues like leaks or damage that could harm your circuit._**
55+
56+
You can read more about capacitors [here](https://learn.sparkfun.com/tutorials/capacitors/all).
2057

2158
## Circuit
2259

23-
Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to positive pole (+) of your power source. The ground wire is typically black or brown and should be connected to the negative pole (-) of your power source.
60+
Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to positive pole (+) of your power source. The ground wire is typically black or brown and should be connected to the negative pole (-) of your power source.
2461

2562
The signal pin is typically yellow or orange and should be connected to PWM pin on the board. In these examples, it is pin number 9.
2663

27-
***Always make sure to power your servo motor with a external power source. Connecting a servo directly to your board will cause your board to behave erratically and can damage your board***
28-
2964
### Knob Circuit
3065

3166
For the **Knob** example, wire the potentiometer so that its two outer pins are connected to power (+5V) and ground, and its middle pin is connected to `A0` on the board. Then, connect the servo motor as shown in the circuit below.
3267

33-
![The Knob Circuit.](assets/servo_circuit_knob.png)
68+
![The Knob Circuit.](./assets/servo_circuit_knob.png)
3469

3570
### Sweep Circuit
3671

3772
For the **Sweep** example, connect the servo motor as shown in the circuit below.
3873

39-
![The Sweep Circuit.](./assets/servo_circuit_sweep.png)
74+
![The Sweep Circuit.](./assets/servo_circuit_knob-pot.png)
4075

4176
## Examples
4277

0 commit comments

Comments
 (0)