Skip to content

Commit 816c798

Browse files
committed
Add docs for the servo hat on the arduino
1 parent bee2e49 commit 816c798

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

content/api/arduino.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,37 @@ distance_metres = u.distance()
132132
If the ultrasound signal never returns, the sensor will timeout and
133133
return `None`.
134134
{{% /notice %}}
135+
136+
## Servos
137+
138+
{{% notice warning %}}
139+
Servos are only available on the [physical robot](/robots/physical/).
140+
{{% /notice %}}
141+
142+
You can control attached servo motors from the servo assembly. By default, servos will be unpowered when your robot starts, and can freely rotate when turned by hand. Upon setting a value, they will hold the corresponding position. They will become unpowered again when you turn off your robot, unplug your USB stick, or set their position to the special value `None`.
143+
144+
## Querying servos
145+
146+
The servo assembly can interface with up to sixteen servos connected to it.
147+
148+
```python
149+
servo_one = r.arduino.servos[1]
150+
```
151+
152+
{{% notice tip %}}
153+
Servo can be connected to any port, you don't have to start at 0!
154+
{{% /notice %}}
155+
156+
## Controlling servos
157+
158+
Servos can be controlled using the `position` parameter. This should be set to a value between -1 and 1.
159+
160+
```python
161+
servo_one.position = 0.65
162+
print(servo_one.position)
163+
>>> 0.65
164+
```
165+
166+
{{% notice tip %}}
167+
When `position` is set to `None`, the servo loses power and can freely rotate. This is the same state they're in at start-up.
168+
{{% /notice %}}

0 commit comments

Comments
 (0)