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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Ben Nuttall
March 21, 2016
Education
0
340
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
460
Live Highlights in BBC iPlayer
bennuttall
0
140
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
200
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
140
Running a Python Package Index for Raspberry Pi
bennuttall
0
170
From Acorns to Raspberries
bennuttall
0
150
Innovation in the newsroom
bennuttall
0
200
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
220
How to market your open source project
bennuttall
0
260
Other Decks in Education
See All in Education
Introduction - Lecture 1 - Next Generation User Interfaces (4018166FNR)
signer
PRO
2
4.5k
Railsチュートリアル × 反転学習の事例紹介
yasslab
PRO
3
170k
Write to Win: Crafting Winning Application Essays
em07adoz
0
140
演習:Gitの応用操作 / 05-git-advanced
kaityo256
PRO
0
230
資格支援制度-株式会社HIT
kabushikigaisya_hit
0
590
Introduction - Lecture 1 - Advanced Topics in Big Data (4023256FNR)
signer
PRO
2
2.3k
SJRC 2526
cbtlibrary
1
220
Pen-based Interaction - Lecture 4 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
2.1k
高校数学とJulia言語
shimizudan
0
140
Chapitre_2_-_Partie_2.pdf
bernhardsvt
2
230
HyRead2526
cbtlibrary
1
230
CoderDojoへようこそ ニンジャ&保護者向け (CoderDojo Guidance for Ninjas&Parents)
coderdojokodaira
1
120
Featured
See All Featured
[SF Ruby Conf 2025] Rails X
palkan
2
840
Designing for Timeless Needs
cassininazir
0
170
Faster Mobile Websites
deanohume
310
31k
Building the Perfect Custom Keyboard
takai
2
720
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.9k
Navigating Weather and Climate Data
rabernat
0
140
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
480
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
490
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
130
Everyday Curiosity
cassininazir
0
170
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
450
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