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
250
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
150
Live Highlights in BBC iPlayer
bennuttall
0
42
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
110
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
64
Running a Python Package Index for Raspberry Pi
bennuttall
0
69
From Acorns to Raspberries
bennuttall
0
53
Innovation in the newsroom
bennuttall
0
69
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
130
How to market your open source project
bennuttall
0
180
Other Decks in Education
See All in Education
お仕事図鑑pitchトーク
tetsuyaooooo
0
2.3k
Ch2_-_Partie_3.pdf
bernhardsvt
0
100
寺沢拓敬 2024. 09. 「言語政策研究と教育政策研究の狭間で英語教育政策を考える」
terasawat
0
200
認知情報科学科_キャリアデザイン_大学院の紹介
yuyakurodou
0
120
老人会? いえ、技術継承です @ builderscon 2024 LT
s3i7h
0
110
PSYC-560 R and R Studio Setup
jdbedics
0
510
Kindleストアで本を探すことの善悪 #Izumo Developers' Guild 第1回 LT大会
totodo713
0
130
construindo uma carreira com opensource
caarlos0
0
240
HCI Research Methods - Lecture 7 - Human-Computer Interaction (1023841ANR)
signer
PRO
0
700
Flip-videochat
matleenalaakso
0
14k
アニメに学ぶチームの多様性とコンピテンシー
terahide
0
240
Master of Applied Science & Engineering: Computer Science & Master of Science in Applied Informatics
signer
PRO
0
430
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
It's Worth the Effort
3n
183
27k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Why Our Code Smells
bkeepers
PRO
334
57k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Music & Morning Musume
bryan
46
6.2k
Designing for humans not robots
tammielis
250
25k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
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