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
310
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
340
Live Highlights in BBC iPlayer
bennuttall
0
96
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
150
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
100
Running a Python Package Index for Raspberry Pi
bennuttall
0
130
From Acorns to Raspberries
bennuttall
0
110
Innovation in the newsroom
bennuttall
0
130
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
190
How to market your open source project
bennuttall
0
230
Other Decks in Education
See All in Education
より良い学振申請書(DC)を作ろう 2025
luiyoshida
1
3.3k
Are puppies a ranking factor?
jonoalderson
0
870
生成AI
takenawa
0
6.9k
データ分析
takenawa
0
6.9k
View Manipulation and Reduction - Lecture 9 - Information Visualisation (4019538FNR)
signer
PRO
1
2.1k
バックオフィス組織にも「チームトポロジー」の考えが使えるかもしれない!!
masakiokuda
0
110
子どものためのプログラミング道場『CoderDojo』〜法人提携例〜 / Partnership with CoderDojo Japan
coderdojojapan
4
16k
Pydantic(AI)とJSONの詳細解説
mickey_kubo
0
120
ビジネスモデル理解
takenawa
0
6.9k
技術文章を書くための執筆技術と実践法(パラグラフライティング)
hisashiishihara
18
6.5k
演習問題
takenawa
0
6.9k
The Art of Note Taking
kanaya
1
140
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
51
8.5k
Six Lessons from altMBA
skipperchong
28
3.9k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.5k
Statistics for Hackers
jakevdp
799
220k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Optimizing for Happiness
mojombo
379
70k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
For a Future-Friendly Web
brad_frost
179
9.8k
Facilitating Awesome Meetings
lara
54
6.4k
A Modern Web Designer's Workflow
chriscoyier
695
190k
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