Skip to content

Commit 1f0556f

Browse files
committed
Copy edit
1 parent 4f2fcff commit 1f0556f

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

worksheet.md

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# Getting started with Physical Computing
1+
# Getting started with physical computing
22

33
## GPIO pins
44

55
One powerful feature of the Raspberry Pi is the row of GPIO pins along the top edge of the board. GPIO stands for General-Purpose Input/Output. These pins are a physical interface between the Raspberry Pi and the outside world. At the simplest level, you can think of them as switches that you can turn on or off (input) or that the Pi can turn on or off (output).
66

7-
The GPIO pins are a way in which the Raspberry Pi can control and monitor the outside world by being connected to electronic circuits. The Pi is able to control LEDs, turning them on or off, or motors, or many other things. It is also able to detect whether a switch has been pressed, or temperature, or light. We refer to this as physical computing.
7+
The GPIO pins allow the Raspberry Pi to control and monitor the outside world by being connected to electronic circuits. The Pi is able to control LEDs, turning them on or off, run motors, and many other things. It's also able to detect whether a switch has been pressed, the temperature, and light. We refer to this as physical computing.
88

9-
There are 40 pins on the Raspberry Pi (26 pins on early models), and the pins provide various different functions.
9+
There are 40 pins on the Raspberry Pi (26 pins on early models), and they provide various different functions.
1010

11-
If you have a RasPIO pin label, it can help to identify what each pin is used for. Make sure your pin label is placed with the keyring hole facing the USB ports, pointed outwards.
11+
If you have a RasPiO pin label, it can help to identify what each pin is used for. Make sure your pin label is placed with the keyring hole facing the USB ports, pointed outwards.
1212

1313
![](images/raspio-ports.jpg)
1414

15-
If you don't have a pin label then this guide can help you to identify the pin numbers:
15+
If you don't have a pin label, then this guide can help you to identify the pin numbers:
1616

1717
![](images/pinout.png)
1818

@@ -25,13 +25,13 @@ You'll see pins labelled as 3V3, 5V, GND and GP2, GP3, etc:
2525
| GP2 | GPIO pin 2 | These pins are for general-purpose use and can be configured as input or output pins |
2626
| ID_SC/ID_SD/DNC | Special purpose pins ||
2727

28-
**WARNING**: If you follow the instructions, then playing about with the GPIO pins is safe and fun. Randomly plugging wires and power sources into your Pi, however, may destroy it, especially if using the 5V pins. Bad things can also happen if you try to connect things to your Pi that use a lot of power; LEDs are fine, motors are not. If you are worried about this, then you might want to consider using an add-on board such as the [Explorer HAT](https://shop.pimoroni.com/products/explorer-hat) until you are confident enough to use the GPIO directly.
28+
**WARNING**: If you follow the instructions, then playing about with the GPIO pins is safe and fun. Randomly plugging wires and power sources into your Pi, however, may destroy it, especially if using the 5V pins. Bad things can also happen if you try to connect things to your Pi that use a lot of power; LEDs are fine, motors are not. If you're worried about this, then you might want to consider using an add-on board such as the [Explorer HAT](https://shop.pimoroni.com/products/explorer-hat) until you're confident enough to use the GPIO directly.
2929

3030
## Lighting an LED
3131

32-
LEDs are delicate little things. If you put too much current through them they will pop (sometimes quite spectacularly). To limit the current going through the LED, you should always use a resitor in series with it.
32+
LEDs are delicate little things. If you put too much current through them they will pop (sometimes quite spectacularly). To limit the current going through the LED, you should always use a resistor in series with it.
3333

34-
Try connecting an LED to the Pi's 3V3 and GND pins with a resistor, anything over about 50Ω should do the trick:
34+
Try connecting an LED to the Pi's 3V3 and GND pins with a resistor. Anything over about 50Ω should do the trick:
3535

3636
![](images/led-3v3.png)
3737

@@ -45,11 +45,11 @@ The LED should now turn off, but now it's on a GPIO pin, and can therefore be co
4545

4646
## Switching an LED on and off
4747

48-
GPIO Zero is a new Python library which provides a simple interface to everyday GPIO components, it comes installed by default in Raspbian
48+
GPIO Zero is a new Python library which provides a simple interface to everyday GPIO components. It comes installed by default in Raspbian.
4949

50-
1. Open IDLE from the main menu (`Menu`>`Programming`>`IDLE (Python 3)`.
50+
1. Open IDLE from the main menu (`Menu`>`Programming`>`Python 3 (IDLE)`.
5151

52-
1. You can switch an LED on and off by typing commands directly into the Python interpretor window (also known as the Python shell). Let's do this by first, importing the GPIO Zero library. You also need to tell the Pi which GPIO pin you are using - in this case pin 17. Next to the chevrons `>>>`, type:
52+
1. You can switch an LED on and off by typing commands directly into the Python interpreter window (also known as the Python **shell**). Let's do this by first importing the GPIO Zero library. You also need to tell the Pi which GPIO pin you are using - in this case pin 17. Next to the chevrons `>>>`, type:
5353

5454
```python
5555
from gpiozero import LED
@@ -58,7 +58,7 @@ GPIO Zero is a new Python library which provides a simple interface to everyday
5858
```
5959
Press **Enter** on the keyboard.
6060

61-
1. To make the LED switch on, type the following and press enter:
61+
1. To make the LED switch on, type the following and press **Enter**:
6262

6363
```python
6464
led.on()
@@ -70,17 +70,15 @@ GPIO Zero is a new Python library which provides a simple interface to everyday
7070
led.off()
7171
```
7272

73-
1. Your LED should switch on and the off again. But that's not all you can do.
73+
1. Your LED should switch on and then off again. But that's not all you can do.
7474

7575
## Flashing an LED
7676

7777
With the help of the `time` library and a little loop, you can make the LED flash.
7878

7979
1. Create a new file by clicking **File > New file**.
8080

81-
1. Save the new file by clicking **File > Save**.
82-
83-
1. Save the file as `gpio_led.py`.
81+
1. Save the new file by clicking **File > Save**. Save the file as `gpio_led.py`.
8482

8583
1. Enter the following code to get started:
8684

@@ -103,19 +101,17 @@ With the help of the `time` library and a little loop, you can make the LED flas
103101

104102
## Using buttons to get input
105103

106-
Now you are able to control an output component - an LED, let's connect and control an input component - a button.
104+
Now you're able to control an output component (an LED), let's connect and control an input component: a button.
107105

108-
1. Connect a button to another GND pin and GPIO pin 2 like this:
106+
1. Connect a button to another GND pin and GPIO pin 2, like this:
109107

110108
![](images/button.png)
111109

112110
1. Create a new file by clicking **File > New file**.
113111

114-
1. Save the new file by clicking **File > Save**.
115-
116-
1. Save the file as `gpio_button.py`.
112+
1. Save the new file by clicking **File > Save**. Save the file as `gpio_button.py`.
117113

118-
1. This time you'll need the Button class, and to tell it that the button is on pin 2. Write the following code in your new file:
114+
1. This time you'll need the `Button` class, and to tell it that the button is on pin 2. Write the following code in your new file:
119115

120116
```python
121117
from gpiozero import Button
@@ -129,17 +125,15 @@ Now you are able to control an output component - an LED, let's connect and cont
129125
print('You pushed me')
130126
```
131127
1. Save with **Ctrl + S** and run the code with **F5**.
132-
1. Press the button for your text to appear.
128+
1. Press the button and your text will appear.
133129

134130
## Manually controlling the LED
135131

136132
You can now combine your two programs written so far to control the LED using the button.
137133

138134
1. Create a new file by clicking **File > New file**.
139135

140-
1. Save the new file by clicking **File > Save**.
141-
142-
1. Save the file as `gpio_control.py`.
136+
1. Save the new file by clicking **File > Save**. Save the file as `gpio_control.py`.
143137

144138
1. Now write the following code:
145139

@@ -185,7 +179,7 @@ With a switch, a single press and release on the button would turn the LED on, a
185179

186180
It would be great if you could make the LED switch on only when the button is being held down. With GPIO Zero, that's easy.
187181

188-
1. There are two methods of the Button class called `when_pressed` and `when_released`. These don't block the flow of the program, so if they are placed in a loop, the program will continue to cycle indefinitely.
182+
1. There are two methods of the `Button` class called `when_pressed` and `when_released`. These don't block the flow of the program, so if they are placed in a loop, the program will continue to cycle indefinitely.
189183

190184
1. Modify your code to look like this:
191185

@@ -208,8 +202,8 @@ It would be great if you could make the LED switch on only when the button is be
208202

209203
There are lots of other things you can control or monitor with your Raspberry Pi. Have a look at the worksheets below, to see how easily this can be done.
210204

211-
[Using an Active Buzzer](buzzer.md)
212-
[Making Traffic Lights](trafficlights.md)
213-
[Using a Light Dependent Resistor](ldr.md)
205+
[Using an active buzzer](buzzer.md)
206+
[Making traffic lights](trafficlights.md)
207+
[Using a light-dependent resistor](ldr.md)
214208
[Using a PIR Sensor](pir.md)
215209
[Using an ultrasonic distance sensor](distance.md)

0 commit comments

Comments
 (0)