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
Ben Nuttall
October 15, 2015
Education
420
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
1
710
Live Highlights in BBC iPlayer
bennuttall
0
180
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
240
Rapid prototyping in BBC News with Python and AWS
bennuttall
0
180
Running a Python Package Index for Raspberry Pi
bennuttall
0
210
From Acorns to Raspberries
bennuttall
0
180
Innovation in the newsroom
bennuttall
0
230
Innovation in the newsroom - MOS Running Order Manager
bennuttall
0
260
How to market your open source project
bennuttall
0
300
Other Decks in Education
See All in Education
医師がスタッフに AI を教えるとき、どんな内容を話しているか
osawaux
1
120
新入社員を「あの子」と呼ばない運動 -PBL その前に- / Stop Calling New Hires "Kids"
aokiplayer
2
830
Geografía y fútbol. Atlanta. la megalópolis del fútbol
juanmartin2026
1
12k
FA26 CLU MS Clinical Psychology New Student Orientation
jdbedics
0
170
sepm-training-sample
levii
0
200
Gitがない時代 インターネットがない時代の 開発話
sapi_kawahara
0
390
Visionary Initiative: Future Intelligence 「未来の知性と社会の礎を築く」|Science Tokyo(東京科学大学)
sciencetokyo
PRO
0
1.6k
Adobe Express
matleenalaakso
2
8.4k
Comentario del plano urbano de Madrid hasta 1860 (1ª parte )
juanmartin2026
1
51k
CLASSIFICATION OF CRUDE DRUGS
pawan5505
0
150
[2026前期火5] 論理学(京都大学文学部 前期 第5回)「 ならばの問題演習・proof net・かつの規則」
yatabe
0
420
Réunion des directrices et directeurs des écoles de la circonscription de Jonzac - 31 août 2026
fmarot
0
110
Featured
See All Featured
A better future with KSS
kneath
240
18k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
WENDY [Excerpt]
tessaabrams
12
39k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.1k
Statistics for Hackers
jakevdp
799
230k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
430
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
580
sira's awesome portfolio website redesign presentation
elsirapls
0
400
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
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