Skip to content

Commit 0a4c229

Browse files
committed
Copy edit
1 parent a53c843 commit 0a4c229

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

motors.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Motors are great for physical computing: they allow you to turn a wheel forwards and backwards, or make something spin around.
44

5-
A motor cannot be controlled directly from the Raspberry Pi's GPIO pins, because it needs a variable supply of 5 volts. This means you need to power it separately. However, motor controller add-on boards can be used to provide this functionality.
5+
A motor can't be controlled directly from the Raspberry Pi's GPIO pins, because it needs a variable supply of 5 volts. This means you need to power it separately. However, motor controller add-on boards can be used to provide this functionality.
66

77
In this guide, you'll be controlling two motors from your Raspberry Pi using Python on the desktop. First, it's best just to learn how to control the motor. Then, once you have it working, you could easily use your code to drive a Raspberry Pi-powered robot by detaching the monitor, mouse, and keyboard and building a robot around a chassis.
88

@@ -22,13 +22,13 @@ You'll need to wire up two motors and your battery pack using the motor controll
2222

2323
![Connect battery pack](images/battery-pack.png)
2424

25-
1. You'll need to know which GPIO pins your motor controller uses. Refer to the board's documentation. This will usually be described as Motor A and Motor B, or MA1, MA2, MB1 and MB2. Make a note of these pin numbers. If you're not sure which is which, you can investigate this next.
25+
1. You'll need to know which GPIO pins your motor controller uses. Refer to the board's documentation. This will usually be described as Motor A and Motor B, or MA1, MA2, MB1, and MB2. Make a note of these pin numbers. If you're not sure which is which, you can investigate this next.
2626

27-
## Output Devices
27+
## Output devices
2828

2929
First, you should learn to control motors by controlling the pins individually.
3030

31-
1. Boot the Pi and open Python 3
31+
1. Boot the Pi and open Python 3.
3232

3333
1. In the shell, enter the following line to import `OutputDevice` from the GPIO Zero library:
3434

@@ -51,7 +51,7 @@ First, you should learn to control motors by controlling the pins individually.
5151
a.on()
5252
```
5353

54-
The motor should now be spinning! If not, check you are addressing the right pin numbers. The two pins should be connected to the same motor. Also check your wiring and your batteries.
54+
The motor should now be spinning! If not, check you are addressing the right pin numbers. The two pins should be connected to the same motor. Also, check your wiring and your batteries.
5555

5656
![Motor forward](images/motor-forward.png)
5757

@@ -114,7 +114,7 @@ First, you should learn to control motors by controlling the pins individually.
114114

115115
## PWM
116116

117-
So far, you have used simple on/off commands to control your motors. PWM (Pulse-width modulation) allows you to control the speed. The `on()` function sets the motor to go at full speed, but you can control this to make the motor go at a fraction of this speed.
117+
So far, you have used simple on/off commands to control your motors. PWM (pulse-width modulation) allows you to control the speed. The `on()` function sets the motor to go at full speed, but you can control this to make the motor go at a fraction of this speed.
118118

119119
1. Since you're going to reuse the same pins in a different way, you'll have to close the connections to the pins. The easiest way to do that is to restart the Python shell by clicking **Shell > Restart shell**.
120120

@@ -124,7 +124,7 @@ So far, you have used simple on/off commands to control your motors. PWM (Pulse-
124124
from gpiozero import PWMOutputDevice
125125
```
126126

127-
1. Create new connections to each of your pins, as before, but using `PWMOutputDevice`:
127+
1. Create new connections to each of your pins as before, but using `PWMOutputDevice`:
128128

129129
```python
130130
a = PWMOutputDevice(4)
@@ -141,7 +141,7 @@ So far, you have used simple on/off commands to control your motors. PWM (Pulse-
141141

142142
The motor should now be spinning at half speed.
143143

144-
1. To turn the motor the opposite direction, turn `a` off (or set its value to `0`) and set `b`'s value to `0.5`:
144+
1. To turn the motor in the opposite direction, turn `a` off (or set its value to `0`) and set `b`'s value to `0.5`:
145145

146146
```python
147147
a.value = 0
@@ -173,15 +173,15 @@ So far, you have used simple on/off commands to control your motors. PWM (Pulse-
173173

174174
The motors should now speed up from 0 (stopped) to 0.1, 0.2 and up to 1.
175175

176-
Be aware, though, that the motor may not move until it gets above a certain speed as there may not be enough power to engage it.
176+
Be aware, though, that the motor may not move until it gets above a certain speed, as there may not be enough power to engage it.
177177

178178
## Motor class
179179

180-
Now you've learned how setting pins high and low can control a motor, you should proceed to using the built-in `Motor` class, which has all the functionality you just learned about, provided in a simple way, including PWM for speed.
180+
Now you've learned how setting pins high and low can control a motor, you should proceed to using the built-in `Motor` class; this has all the functionality you just learned about, provided in a simple way, including PWM for speed.
181181

182182
![Motor](images/motor.png)
183183

184-
1. Restart the shell again (**Ctrl + F6**)
184+
1. Restart the shell again (**Ctrl + F6**).
185185

186186
1. Import the `Motor` class:
187187

@@ -198,7 +198,7 @@ Now you've learned how setting pins high and low can control a motor, you should
198198

199199
Note: to make it easier to see which pin is which, you can use `Motor(forward=4, backward=14)` for future reference.
200200

201-
1. Now drive one of the motors forward using:
201+
1. Now drive one of the motors forward using the following code:
202202

203203
```python
204204
motor1.forward()
@@ -217,7 +217,7 @@ Now you've learned how setting pins high and low can control a motor, you should
217217
motor2.backward(0.5)
218218
```
219219

220-
1. The `Motor` class also allows you to reverse the motor's direction. Try using this a loop:
220+
1. The `Motor` class also allows you to reverse the motor's direction. Try using this loop:
221221

222222
```python
223223
motor1.forward()
@@ -228,7 +228,7 @@ Now you've learned how setting pins high and low can control a motor, you should
228228
motor2.reverse()
229229
```
230230

231-
This will make the motors spin in opposite directions, then switching every five seconds. Press **Ctrl + C** to exit the loop.
231+
This will make the motors spin in opposite directions, then switch every five seconds. Press **Ctrl + C** to exit the loop.
232232

233233
1. Now stop the motors:
234234

@@ -239,11 +239,11 @@ Now you've learned how setting pins high and low can control a motor, you should
239239

240240
## Robot class
241241

242-
If you had a robot with two wheels, you would want to control the two motors together, rather than separately, just like you did for the two pins of each motor. Luckily, there's also a `Robot` class in GPIO Zero.
242+
If you had a robot with two wheels you would want to control the two motors together, rather than separately, just like you did for the two pins of each motor. Luckily, there's also a `Robot` class in GPIO Zero.
243243

244244
![Robot](images/robot.png)
245245

246-
1. Restart the shell again (**Ctrl + F6**)
246+
1. Restart the shell again (**Ctrl + F6**).
247247

248248
1. Import the `Motor` class:
249249

@@ -259,7 +259,7 @@ If you had a robot with two wheels, you would want to control the two motors tog
259259

260260
Note: to make it easier to see which pin is which, you can use `Robot(left=(4, 14), right=(17, 27))` for future reference.
261261

262-
1. Now drive one of the motors forward using:
262+
1. Now drive one of the motors forward using the following code:
263263

264264
```python
265265
robot.forward()
@@ -311,5 +311,5 @@ If you had a robot with two wheels, you would want to control the two motors tog
311311

312312
Now you've learned how motors work, why not try:
313313

314-
- Making your own robot with our [Build a robot](http://raspberrypi.org/learning/robo-butler/) resource
315-
- Make a [spinning flower wheel](http://raspberrypi.org/learning/spinning-flower-wheel/)
314+
- Making your own robot with our [Build a robot](http://raspberrypi.org/learning/robo-butler/) resource?
315+
- Making a [spinning flower wheel](http://raspberrypi.org/learning/spinning-flower-wheel/)?

0 commit comments

Comments
 (0)