Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Physical computing with Scratch and Python
Search
Ben Nuttall
March 21, 2016
Education
0
290
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
Numeronyms are obnoxious
bennuttall
0
280
Live Highlights in BBC iPlayer
bennuttall
0
79
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
140
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
91
Running a Python Package Index for Raspberry Pi
bennuttall
0
110
From Acorns to Raspberries
bennuttall
0
89
Innovation in the newsroom
bennuttall
0
110
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
160
How to market your open source project
bennuttall
0
210
Other Decks in Education
See All in Education
Design Guidelines and Principles - Lecture 7 - Information Visualisation (4019538FNR)
signer
PRO
0
2.3k
子どものためのプログラミング道場『CoderDojo』〜法人提携例〜 / Partnership with CoderDojo Japan
coderdojojapan
4
15k
Visualisation Techniques - Lecture 8 - Information Visualisation (4019538FNR)
signer
PRO
0
2.3k
Analysis and Validation - Lecture 4 - Information Visualisation (4019538FNR)
signer
PRO
0
2k
環境・社会理工学院 建築学系 大学院入試について|Science Tokyo(東京科学大学)
sciencetokyo
PRO
0
720
zupanijska natjecanja
petarradanovic2
0
330
複式簿記から純資産を排除する/eliminate_net_assets_from_double-entry_bookkeeping
florets1
1
350
家族をスクラムチームに! アジャイルで取り組む家事と育児 | Install Scrum to Family
coosuke
PRO
1
250
SkimaTalk Teacher Guidelines
skimatalk
0
730k
FinOpsスキルの効率的な上げ方 #ochacafe
chacco38
1
130
OpenAI Education Forum 資料「教育と生成AI ~事例から見えるこれからの活用~」
luiyoshida
1
600
Gaps in Therapy in IBD - IBDInnovate 2025 CCF
higgi13425
0
430
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
522
39k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
13
660
A Tale of Four Properties
chriscoyier
158
23k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.1k
The Cost Of JavaScript in 2023
addyosmani
49
7.7k
4 Signs Your Business is Dying
shpigford
183
22k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
GraphQLの誤解/rethinking-graphql
sonatard
71
10k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
It's Worth the Effort
3n
184
28k
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