Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Physical computing with Scratch and Python
Ben Nuttall
March 21, 2016
Education
0
190
Physical computing with Scratch and Python
Physical computing with Raspberry Pi using Scratch and Python with GPIO Zero
Ben Nuttall
March 21, 2016
Tweet
Share
More Decks by Ben Nuttall
See All by Ben Nuttall
Running a Python Package Index for Raspberry Pi
bennuttall
0
18
From Acorns to Raspberries
bennuttall
0
8
Innovation in the newsroom
bennuttall
0
15
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
40
How to market your open source project
bennuttall
0
79
Manage your own Pi Cloud with hostedpi
bennuttall
0
38
Tools for maintaining an open source project
bennuttall
0
37
Tools for maintaining an open source Python project
bennuttall
0
66
piwheels: a Python package repository for Raspberry Pi
bennuttall
0
34
Other Decks in Education
See All in Education
Interaction - Lecture 10 - Information Visualisation (4019538FNR)
signer
PRO
0
440
American Progress: John Gast's Spirit of Manifest Destiny
oripsolob
0
680
Classi_会社紹介資料
classijp
7
34k
20220511pmtipslt
levii
0
250
20220305ISECON
levii
0
190
Studio Ghibli + Campus Júnior
joantubau
0
530
多様なメンター、多様な基準
yasulab
4
13k
Svyati
libshare
0
150
実践事例発表4「自学自習によるプログラミング入門」
asial_edu
0
170
Baparekraf Developer Day 2022 - Cyber Security (Ardi Sutedja)
dicodingevent
0
420
東海大学特別講義 2022 前半資料
1ftseabass
PRO
0
220
子どものためのプログラミング道場『CoderDojo』〜法人提携例〜 / Partnership with CoderDojo Japan
coderdojojapan
5
6.5k
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_i
21
14k
The Power of CSS Pseudo Elements
geoffreycrofte
46
3.9k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
38
12k
Designing the Hi-DPI Web
ddemaree
272
32k
Raft: Consensus for Rubyists
vanstee
126
5.4k
Ruby is Unlike a Banana
tanoku
91
9.2k
Fantastic passwords and where to find them - at NoRuKo
philnash
25
1.4k
What’s in a name? Adding method to the madness
productmarketing
11
1.5k
The World Runs on Bad Software
bkeepers
PRO
56
5.2k
How GitHub Uses GitHub to Build GitHub
holman
465
280k
Rebuilding a faster, lazier Slack
samanthasiow
62
7.2k
Making Projects Easy
brettharned
98
4.3k
Transcript
Physical Computing with Scratch and Python
None
Boot the Pi and open Scratch
GPIO Server • GPIO Server On
Broadcast • configXout • gpioXon • gpioXoff • wait X
secs • forever Component GPIO pin Red LED 25 Amber LED 8 Green LED 7 Buzzer 15
Close Scratch and open Python 3
Open a new file • File > New File •
File > Save • Save as camjam.py
GPIO Zero LED from gpiozero import LED led = LED(25)
while True: led.on() sleep(1) led.off() sleep(1) Save and run: Ctrl + S F5
GPIO Zero LED from gpiozero import LED led = LED(25)
led.blink()
GPIO Zero Button + LED from gpiozero import Button, LED
button = Button(21) led = LED(25) while True: button.wait_for_press() led.on() button.wait_for_release() led.off()
GPIO Zero Button + LED from gpiozero import Button, LED
button = Button(21) led = LED(25) while True: led.on() button.wait_for_press() led.off() button.wait_for_release()
GPIO Zero Button + LED from gpiozero import Button, LED
button = Button(21) led = LED(25) while True: led.blink() button.wait_for_press() led.off() button.wait_for_release()
Traffic Lights from gpiozero import Button, TrafficLights button = Button(21)
lights = TrafficLights(25, 8, 7) while True: button.wait_for_press() lights.on() button.wait_for_release() lights.off()
Traffic Lights from gpiozero import Button, TrafficLights button = Button(21)
lights = TrafficLights(25, 8, 7) while True: lights.blink() button.wait_for_press() lights.on() button.wait_for_release()
Traffic Lights from gpiozero import Button, TrafficLights, Buzzer from time
import sleep button = Button(21) lights = TrafficLights(25, 8, 7) buzzer = Buzzer(15) while True: lights.on() buzzer.off() button.wait_for_press() lights.off() buzzer.on() button.wait_for_release()
Traffic Lights while True: lights.green.on() sleep(1) lights.amber.on() sleep(1) lights.red.on() sleep(1)
lights.off()
Traffic Lights while True: button.wait_for_press() lights.green.on() sleep(1) lights.amber.on() sleep(1) lights.red.on()
sleep(1) lights.off()
Traffic Lights Sequence • Can you make a full traffic
lights sequence? • Use the button for a pedestrian crossing • Use buzzer.beep() to indicate safe crossing
Documentation and help guides • raspberrypi.org/documentation/usage/scratch/gpio • gpiozero.readthedocs.org • raspberrypi.org/resources
• raspberrypi.org/education/downloads
Physical Computing with Scratch and Python