Formatting bug
This commit is contained in:
parent
f72cb685ef
commit
0428471f9d
3 changed files with 13 additions and 13 deletions
BIN
images/IMG_2406.JPG
Normal file
BIN
images/IMG_2406.JPG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
BIN
images/four-prong-button.png
Normal file
BIN
images/four-prong-button.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 746 KiB |
|
|
@ -6,17 +6,17 @@ With the hardware set up, we can begin to program the software that will make ev
|
|||
|
||||
1. To begin, open the file explorer, then right click on a blank space inside the file explorer window.
|
||||
|
||||

|
||||

|
||||
|
||||
1. Select `Create new` and then click `Folder`
|
||||
|
||||

|
||||

|
||||
|
||||
1. Type in the name of the folder where you will store the code and the photographs. We chose to call ours `allseeingpi`. Make a note of the path to this folder which is displayed in the bar at the top, which should be `/home/pi/allseeingpi`
|
||||
|
||||
1. From the "Programming" menu, open up "Python 3"
|
||||
|
||||

|
||||

|
||||
|
||||
1. Create a new Python file by clicking on `File` > `New File`.
|
||||
|
||||
|
|
@ -24,23 +24,23 @@ With the hardware set up, we can begin to program the software that will make ev
|
|||
|
||||
1. We will need the `gpiozero` library. At the start of your Python file add an import statement:
|
||||
|
||||
```python
|
||||
from gpiozero import Button
|
||||
```
|
||||
```python
|
||||
from gpiozero import Button
|
||||
```
|
||||
|
||||
1. Next we will set up the buttons. On the [previous worksheet](worksheet.md) we wired our buttons to pins 23 and 25. Let's go ahead and set both buttons up.
|
||||
|
||||
```python
|
||||
next_overlay_btn = Button(23)
|
||||
take_pic_btn = Button(25)
|
||||
```
|
||||
```python
|
||||
next_overlay_btn = Button(23)
|
||||
take_pic_btn = Button(25)
|
||||
```
|
||||
|
||||
1. Now we will use gpiozero to tell the buttons what to do when pressed. In the code below, `next_overlay` and `take_picture` are functions which will be called when the corresponding button is pressed:
|
||||
|
||||
```python
|
||||
```python
|
||||
next_overlay_btn.when_pressed = next_overlay
|
||||
take_pic_btn.when_pressed = take_picture
|
||||
```
|
||||
```
|
||||
|
||||
1. We will write these two functions so that the buttons know what to do when they are pressed. Functions are usually written at the start of a program immediately after the `import` statements. Add the functions, but with some placeholder code to just print a message when they are pressed, so we can test them.
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ With the hardware set up, we can begin to program the software that will make ev
|
|||
|
||||
def take_picture():
|
||||
print("Take a picture")
|
||||
```
|
||||
```
|
||||
|
||||
1. Press `F5`, save and run your program. Try pressing each button and check that a different message pops up for each in the Python shell.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue