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 GPIO Zero
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Ben Nuttall
October 15, 2015
Education
400
1
Share
Physical computing with GPIO Zero
Short talk in my new GPIO Python library for Raspberry Pi, given at Coding Evening in London
Ben Nuttall
October 15, 2015
More Decks by Ben Nuttall
See All by Ben Nuttall
Numeronyms are obnoxious
bennuttall
0
480
Live Highlights in BBC iPlayer
bennuttall
0
150
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
210
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
150
Running a Python Package Index for Raspberry Pi
bennuttall
0
180
From Acorns to Raspberries
bennuttall
0
160
Innovation in the newsroom
bennuttall
0
210
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
230
How to market your open source project
bennuttall
0
270
Other Decks in Education
See All in Education
アントレプレナーシップ教育機構 概要
sciencetokyo
PRO
0
2.9k
【セーフィー】テクニカルライティング&コミュニケーション実践講座(26新卒エンジニア向け研修資料)
ymzaki_m4
0
130
Pen-based Interaction - Lecture 4 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
2.3k
Virtual and Augmented Reality - Lecture 8 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
2.2k
Interactive Tabletops and Surfaces - Lecture 5 - Next Generation User Interfaces (4018166FNR)
signer
PRO
1
2.2k
演習:Gitの基本操作 / 04-git-basic
kaityo256
PRO
1
500
「機械学習と因果推論」入門① 因果効果とは
masakat0
0
1.7k
Course Review - Lecture 13 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
2.2k
The Art & Science of Elearning
tmiket
1
190
生成AIを授業の相棒にするデータサイエンス入門(「デジタル✕探究」イノベーターズフォーラム テクニカルセッション講演資料)
datascientistsociety
PRO
0
220
GitHubによるWebアプリケーションのデプロイ / 07-github-deploy
kaityo256
PRO
2
280
[2026前期火5] 論理学(京都大学文学部 前期 第5回)「 ならばの問題演習・proof net・かつの規則」
yatabe
0
140
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
From π to Pie charts
rasagy
0
180
KATA
mclloyd
PRO
35
15k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Ruling the World: When Life Gets Gamed
codingconduct
0
230
Deep Space Network (abreviated)
tonyrice
0
130
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
300
Discover your Explorer Soul
emna__ayadi
2
1.1k
Building Applications with DynamoDB
mza
96
7k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
130
The SEO Collaboration Effect
kristinabergwall1
1
440
Transcript
Physical computing with GPIO Zero Ben Nuttall Raspberry Pi Foundation
UK Charity 1129409
Ben Nuttall • Education Developer Advocate at the Raspberry Pi
Foundation – Software & project development – Learning resources & teacher training – Outreach • Hobbyist turned employee • Based in Cambridge • @ben_nuttall on Twitter
Python – RPi.GPIO import RPi.GPIO as GPIO from time import
sleep GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) led = 17 GPIO.setup(led, GPIO.OUT) while True: GPIO.output(led, True) sleep(1) GPIO.output(led, False) sleep(1)
Python – GPIO Zero from gpiozero import LED from time
import sleep led = LED(17) while True: led.on() sleep(1) led.off() sleep(1)
LED from gpiozero import LED from time import sleep led
= LED(17) led.on() # on led.off() # off led.toggle() # on>off or off>on led.blink() # flash on/off continuously
LED + Button from gpiozero import LED, Button led =
LED(17) button = Button(3) button.when_pressed = led.on button.when_released = led.off
Motion sensor from gpiozero import LED, MotionSensor led = LED(2)
sensor = MotionSensor(3) sensor.when_motion = led.on sensor.when_no_motion = led.off
Traffic Lights from gpiozero import TrafficLights lights = TrafficLights(9, 10,
11) lights.on() # all on lights.off() # all off lights.red.on() # red on lights.toggle() # swap state of all lights
Traffic Lights sequence lights.green.on() lights.amber.off() lights.red.off() while True: sleep(10) lights.green.off()
lights.amber.on() sleep(1) lights.amber.off() lights.red.on() sleep(10) lights.amber.on() sleep(1) lights.green.on() lights.amber.off() lights.red.off()
Full colour LED from gpiozero import RGBLED led = RGBLED(2,
3, 4) led.red.on() # full red led.color = (255, 0, 255) # purple led.blue = 100 # dim the blue value to 100 # now (255, 0, 100)
Motor from gpiozero import Motor from time import sleep motor
= Motor(forward=17, back=18) while True: motor.forward() sleep(5) motor.backward() sleep(5)
Robot from gpiozero import Robot from time import sleep robot
= Robot(left=(17, 18), right=(22, 23)) while True: robot.forward() sleep(10) robot.left() sleep(1)
Button controlled Robot from gpiozero import RyanteckRobot, Button robot =
RyanteckRobot() left = Button(26) right = Button(16) fw = Button(21) bw = Button(20) fw.when_pressed = robot.forward fw.when_released = robot.stop left.when_pressed = robot.left left.when_released = robot.stop right.when_pressed = robot.right right.when_released = robot.stop bw.when_pressed = robot.backward bw.when_released = robot.stop
Analogue - potentiometers from gpiozero import RGBLED, MCP3008 led =
RGBLED(2, 3, 4) pot = MCP3008() while True: red = pot.value led.color = (red, 0, 0) # set brightness of red
GPIO Zero - beta • www.pythonhosted.org/gpiozero – Installation instructions –
Documentation – Examples • Google Doc (linked from documentation) – Suggestions – Feedback • Contact me –
[email protected]
– @ben_nuttall on Twitter • #gpiozero on Twitter
CamJam EduKit • £5 starter kit (kit 1) • £7
sensors kit (kit 2) • £17 robotics kit (kit 3) • Free worksheets • Very reusable
Physical computing with GPIO Zero Ben Nuttall Raspberry Pi Foundation
UK Charity 1129409