You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: programming/servos.md
+31-35Lines changed: 31 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,64 +6,60 @@ title: Servos Board API
6
6
Servos Board API
7
7
================
8
8
9
-
The `servo_board` object is used to control a collection of Servo Boards.
9
+
The kit can control multiple servos.
10
+
One servo board can control up to 12 servos.
11
+
See the [Servo Board](/docs/kit/servo_board) hardware page for more details about this board.
10
12
11
-
When a single Servo Board is connected to your robot, you can control it
12
-
using the `servo_board` object.
13
13
14
-
~~~~~python
15
-
R.servo_board.something...
16
-
~~~~~
17
-
18
-
The serial number of each detected Servo Board is printed to the log when your robot starts.
19
-
It will look something like this:
20
-
21
-
~~~~~not-code
22
-
sr.robot3.robot INFO - Found Student Robotics Servo Board v4 - srABC1
23
-
~~~~~
14
+
Accessing the Servo Board
15
+
-------------------------
24
16
25
-
If you have more than one Servo Board attached, you need to specify which one you want to control. This is done using the serial number of the board. For example: if you had a board that was labelled "srABC1",
17
+
The servo board can be accessed using the `servo_board` property of the `Robot` object.
26
18
27
19
~~~~~python
28
-
R.servo_boards["srABC1"].something...
20
+
from sr.robot3 import*
21
+
robot = Robot()
22
+
23
+
my_servo_board = robot.servo_board
29
24
~~~~~
30
25
31
-
<divclass="warning"markdown="1">
32
-
When you have more than one servo board connected to your kit,
33
-
you must use `R.servo_boards` and index by serial number. This is so
34
-
that the kit knows which servo board you want to control.
35
-
</div>
36
26
37
27
Setting servo positions
38
28
-----------------------
39
29
40
-
Each of the twelve servo outputs can be controlled separately. The servo outputs
41
-
are numbered 0-11, see the [Servo Board](/docs/kit/servo_board#connectors) docs
42
-
for details of which output is which.
30
+
Each of the twelve servo outputs can be controlled separately.
31
+
The servo outputs are numbered 0-11, see the [Servo Board](/docs/kit/servo_board#connectors) docs for details of which output is which.
32
+
33
+
This board object has an array containing the servos connected to it, which can be accessed as servos[0], servos[1], servos[2], etc.
34
+
The servo board is labelled so you know which servo is which.
43
35
44
36
The position of servos can range from `-1` to `1` inclusive:
0 commit comments