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
440
Live Highlights in BBC iPlayer
bennuttall
0
130
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
190
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
130
Running a Python Package Index for Raspberry Pi
bennuttall
0
160
From Acorns to Raspberries
bennuttall
0
140
Innovation in the newsroom
bennuttall
0
190
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
210
How to market your open source project
bennuttall
0
260
Other Decks in Education
See All in Education
Node-REDで広がるプログラミング教育の可能性
ueponx
1
260
【洋書和訳:さよならを待つふたりのために】第2章 ガン特典と実存的フリースロー
yaginumatti
0
210
【洋書和訳:さよならを待つふたりのために】第1章 出会いとメタファー
yaginumatti
0
220
悩める リーダー達に 届けたい書籍|レジリエントマネジメント 書籍イントロダクション-260126
mimoza60
0
160
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
核軍備撤廃に向けた次の大きな一歩─核兵器を先には使わないと核保有国が約束すること
hide2kano
0
230
The Next Big Step Toward Nuclear Disarmament
hide2kano
0
210
Adobe Express
matleenalaakso
1
8.1k
ThingLink
matleenalaakso
28
4.3k
滑空スポーツ講習会2025(実技講習)EMFT学科講習資料/JSA EMFT 2025
jsaseminar
0
220
国際卓越研究大学計画|Science Tokyo(東京科学大学)
sciencetokyo
PRO
0
47k
Surviving the surfaceless web
jonoalderson
0
340
Featured
See All Featured
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
220
Agile that works and the tools we love
rasmusluckow
331
21k
Design in an AI World
tapps
0
140
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.1k
Mind Mapping
helmedeiros
PRO
0
77
How GitHub (no longer) Works
holman
316
140k
The SEO Collaboration Effect
kristinabergwall1
0
350
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.5k
Amusing Abliteration
ianozsvald
0
96
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
170
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