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
270
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
200
Live Highlights in BBC iPlayer
bennuttall
0
58
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
120
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
76
Running a Python Package Index for Raspberry Pi
bennuttall
0
85
From Acorns to Raspberries
bennuttall
0
66
Innovation in the newsroom
bennuttall
0
83
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
140
How to market your open source project
bennuttall
0
190
Other Decks in Education
See All in Education
JavaScript - Lecture 6 - Web Technologies (1019888BNR)
signer
PRO
0
2.6k
HTML5 and the Open Web Platform - Lecture 3 - Web Technologies (1019888BNR)
signer
PRO
1
2.6k
Informasi Program Coding Camp 2025 powered by DBS Foundation
codingcamp2025
0
140
Comment aborder et contribuer sereinement à un projet open source ? (Masterclass Université Toulouse III)
pylapp
0
3.3k
Algo de fontes de alimentación
irocho
1
470
ThingLink
matleenalaakso
28
3.8k
Use Cases and Course Review - Lecture 8 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
830
TP5_-_UV.pdf
bernhardsvt
0
130
Evaluation Methods - Lecture 6 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
780
20241004_Microsoft認定資格のFundamentals全部取ってみた
ponponmikankan
2
390
自己紹介 / who-am-i
yasulab
PRO
2
4.4k
<学びの作品化>を促す 学習環境デザインの検討―表現方法の多様さが保障された授業に着目して― /jaet2024
kiriem
0
300
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Docker and Python
trallard
43
3.2k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
A Modern Web Designer's Workflow
chriscoyier
693
190k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
The Invisible Side of Design
smashingmag
299
50k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Six Lessons from altMBA
skipperchong
27
3.6k
Bash Introduction
62gerente
610
210k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
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