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
210
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
43
Live Highlights in BBC iPlayer
bennuttall
0
21
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
88
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
43
Running a Python Package Index for Raspberry Pi
bennuttall
0
55
From Acorns to Raspberries
bennuttall
0
34
Innovation in the newsroom
bennuttall
0
48
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
98
How to market your open source project
bennuttall
0
130
Other Decks in Education
See All in Education
Information Architectures - Lecture 2 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
1.1k
リンゴゲームと貧富の差 / Origin of the disparity of wealth
kaityo256
PRO
12
13k
aportacions valors 2024
cumclavis
PRO
0
100
Railsチュートリアルの歩き方 (第7版)
yasslab
PRO
1
1M
Data Representation - Lecture 3 - Information Visualisation (4019538FNR)
signer
PRO
1
1.7k
Tangible, Embedded and Embodied Interaction - Lecture 9 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
1.2k
Hybridation des canaux de distribution
martine
1
1.1k
WordPressを教える人のための視点と考え方
crebowinfo
0
210
「小・中・高等学校における情報教育の体系的な学習を目指したカリキュラムモデル基本方針」
codeforeveryone
0
590
財務分析 - 入門編
lsuzuki
0
320
RE:HACK 2023 - Reverse Engineering and Binary Exploitation: Intel x86/x86-x64 Assembly
x86fatah
1
180
LightSail2324
cbtlibrary
0
110
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
113
18k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
355
22k
What's in a price? How to price your products and services
michaelherold
236
11k
Building an army of robots
kneath
300
41k
Creatively Recalculating Your Daily Design Routine
revolveconf
209
11k
GraphQLの誤解/rethinking-graphql
sonatard
48
9.1k
KATA
mclloyd
14
11k
How to Ace a Technical Interview
jacobian
272
22k
Optimizing for Happiness
mojombo
369
69k
Typedesign – Prime Four
hannesfritz
36
2k
How to train your dragon (web standard)
notwaldorf
71
5.1k
Web Components: a chance to create the future
zenorocha
304
41k
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