SlideShare a Scribd company logo
Physical computing
with Python and Raspberry Pi
Ben Nuttall
Raspberry Pi Foundation
Physical computing with Python and Raspberry Pi
Ben Nuttall
● Education Developer Advocate at Raspberry Pi Foundation
– Software & project development
– Learning resources & teacher training
– Outreach
● Based in Cambridge, UK
● @ben_nuttall on Twitter
● Speaker at EuroPython, PyConUK, PySS, PyCon Ireland & EuroSciPy
in 2014
Raspberry Pi 2
● 900MHz quad core ARM7
● 1GB RAM
● Backwards-compatible with Pi 1
● Same form factor as B+
● Still $35 (B+ now $25, A+ $20)
All about Education
● Raspberry Pi Foundation, registered UK charity 1129409
● Founded in 2009 to aid computing education
● On general sale since 2012, available to all worldwide
– Sold to education, industry and hobbyists
– Sold 6 million to date
● Free learning resources for makers and educators
● Free teacher training - Picademy (currently UK, soon USA)
Ben Croston – beer brewing
Dave Jones - microscopy
picamera.readthedocs.org
Raspbian
● Foundation-issued Debian-based distribution
– Currently based on Wheezy
– Jessie image coming soon
● Image supports Pi 1 and Pi 2
● Software pre-installed
– Python 3 (also Python 2), Ruby, Java, Mathematica, etc.
– GPIO, Picamera, (soon pip too)
● Alternative distributions are available, but not supported, e.g:
– Ubuntu MATE (Pi 2)
– Ubuntu Snappy Core (Pi 2)
– Arch Linux
www.raspberrypi.org/downloads
GPIO Pins – General Purpose Input/Output
rasp.io
Analogue?
● No native analogue on Raspberry Pi
● Options:
– Analogue inputs can be read via ADC
– Various Arduino-compatible add-on boards available
– Use PySerial to read Arduino inputs over USB
Python library - RPi.GPIO
● Included in Raspbian
● Implemented in C
● Features:
– Configure pins as input/output
– Read inputs (high/low)
– Set outputs (high low)
– Wait for edge (wait for input to go high/low)
– Pin event detection (callback on input pin change)
3V3 = always on
GPIO = user controllable
Flash LED with RPi.GPIO
from RPi import GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
led = 2
GPIO.setup(led, GPIO.OUT)
while True:
    GPIO.output(led, True)
    sleep(1)
    GPIO.output(led, False)
    sleep(1)
Push button stop motion
Push button stop motion
from picamera import PiCamera
from RPi import GPIO
from time import sleep
button = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(button, GPIO.IN, GPIO.PUD_UP)
Push button stop motion
with PiCamera() as camera:
    camera.start_preview()
    frame = 1
    while True:
        GPIO.wait_for_edge(button, GPIO.FALLING)
        camera.capture('/home/pi/animation/frame%03d.jpg' % frame)
        frame += 1
    camera.stop_preview()
GPIO Music Box
GPIO Music Box – GPIO events
GPIO.add_event_detect(
    button,
    GPIO.FALLING,
    callback=play,
    bouncetime=1000
)
www.raspberrypi.org/learning/gpio-music-box/
GPIO Music Box – GPIO events
sound_pins = {
    2: drum,
    3: cymbal,
}
def play(pin):
    sound = sound_pins[pin]
    sound.play()
www.raspberrypi.org/learning/gpio-music-box/
CamJam EduKit
camjam.me/edukit
The Gertboard
Ryanteck RPi Motor Controller Board
Pimoroni - Pibrella
Pibrella – traffic lights
import pibrella
from time import sleep
pibrella.light.green.on()
sleep(1)
pibrella.light.amber.on()
sleep(1)
pibrella.light.red.on()
Pibrella – button press event
def flash(pin):
    pibrella.light.on()
    sleep(1)
    pibrella.light.off()
pibrella.button.pressed(flash)
Energenie – remote controlled power sockets
Energenie – remote controlled power sockets
import energenie
from time import sleep
energenie.switch_on()
sleep(5)
energenie.switch_off()
pythonhosted.org/energenie
Energenie – web app
pythonhosted.org/energenie
/examples/web/
26->40 pin header
Raspberry Pi HATs – Hardware Attached on Top
Sous Vide cooking
Chef HAT
WIP – github.com/bennuttall/chef-hat
pypi.python.org/pypi/chef-hat
Chef HAT – temperature moderation
if self.temperature < self.target_temperature:
    self.turn_cooker_on()
else:
    self.turn_cooker_off()
DOTS board
www.raspberrypi.org/dots
DOTS board software
def get_selected_colors():
    return [COLOR_PINS[pin] for pin in COLOR_PINS if pin_is_active(pin)]
def enough_dots_connected():
    active_pins = sum(pin_is_active(pin) for pin in DOT_PINS)
    return active_pins > MINIMUM_DOTS_REQUIRED
def pin_is_active(pin):
    GPIO.setup(pin, GPIO.IN, GPIO.PUD_UP)
    state = GPIO.input(pin)
    GPIO.setup(pin, GPIO.IN, GPIO.PUD_OFF)
    return state == 0
pypi.python.org/pypi/rpi-dots
Plantpot Greenhouse
Capacitive Touch HAT
Pimoroni - HATs
http://shop.pimoroni.com/collections/hats
Weather Station kit
Astro Pi
Astro Pi / Sense HAT
● 8x8 RGB LED matrix
● Temperature
● Humidity
● Pressure
● Accelerometer
● Gyroscope
● Magnetometer
● Mini joystick
pypi.python.org/pypi/astro-pi
Physical computing with Python and Raspberry Pi
Thank you - any questions?

More Related Content

What's hot (15)

PPTX
Raspberry
Sateesh Kaatnam
 
PPTX
Introduction to Raspberry Pi
ehrenbrav
 
PDF
Introduction to ipython notebook
Go Asgard
 
PPTX
Raspberry pi
Sachin More
 
ODP
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
Avansa Mid- en Zuidwest
 
PDF
Raspberry Pi for Developers and Makers
All Things Open
 
PPTX
Dev guide to the IoT (IBM stack)
Artur Basak
 
PDF
Python in a real life
Vladimir Filonov
 
PDF
Interfacing the Raspberry Pi to the World
Omer Kilic
 
PDF
Introduction to IPython & Notebook
Areski Belaid
 
PDF
PyPy London Demo Evening 2013
Carl Friedrich Bolz
 
PPTX
Exploring the abc's of raspberry pi and python(day 2)
Shahed Mehbub
 
PPTX
LED Blinking Using Raspberry Pi
Arjun R Krishna
 
PPTX
Exploring the ABC's of Raspberry Pi with Python
Shahed Mehbub
 
PPTX
Up and running with Raspberry Pi
Shahed Mehbub
 
Raspberry
Sateesh Kaatnam
 
Introduction to Raspberry Pi
ehrenbrav
 
Introduction to ipython notebook
Go Asgard
 
Raspberry pi
Sachin More
 
DigiPinguïns: demo Raspberry Pi (Koen De Smet)
Avansa Mid- en Zuidwest
 
Raspberry Pi for Developers and Makers
All Things Open
 
Dev guide to the IoT (IBM stack)
Artur Basak
 
Python in a real life
Vladimir Filonov
 
Interfacing the Raspberry Pi to the World
Omer Kilic
 
Introduction to IPython & Notebook
Areski Belaid
 
PyPy London Demo Evening 2013
Carl Friedrich Bolz
 
Exploring the abc's of raspberry pi and python(day 2)
Shahed Mehbub
 
LED Blinking Using Raspberry Pi
Arjun R Krishna
 
Exploring the ABC's of Raspberry Pi with Python
Shahed Mehbub
 
Up and running with Raspberry Pi
Shahed Mehbub
 

Viewers also liked (20)

PDF
Raspberry Pi + Python
Daker Fernandes
 
PDF
Iphoneで良い音楽を聞く方法
Kyohei Morimoto
 
PDF
How I Learned To Stop Worrying (And Love The KiCad)
ChrisGammell
 
PDF
ビル・ゲイツ「学校では教えてくれない人生に役立つ11のルール」
Courslide
 
PDF
AKIBAX2010 新ブーム「電子工作」を体験しよう!
encafe
 
PDF
これからの音楽はハイレゾだ!
Courslide
 
PPTX
Why (and how) to switch to KiCad
Baoshi Zhu
 
ODP
Designing with KiCAD of 64-bit ARM board
Olimex Bulgaria
 
PDF
Raspberry Pi - Lecture 5 Python for Raspberry Pi
Mohamed Abdallah
 
PDF
Picademy 5 Picamera Intro Workshop
bennuttall
 
PDF
Raspberry PiのUSB OTGを試す
Kenichiro MATOHARA
 
PPTX
Building the Internet of Things with Raspberry Pi
Neil Broers
 
PDF
技適なBluetooth GNSS/GPSレシーバーをRaspberryPiで作りたい
Kenichiro MATOHARA
 
PDF
プログラミング言語の理念いろいろ
Tomoki Suzuki
 
PPTX
Raspberry Piで 初心者が 半日でできる電子工作 を考えてみた
VirtualTech Japan Inc./Begi.net Inc.
 
PDF
Picademy #3 Python Picamera GPIO Workshop
bennuttall
 
ODP
Raspberry Pi Zero
Baoshi Zhu
 
PPT
Raspberry-Pi
Rehan Fazal
 
PDF
Hands on Raspberry Pi - Creative Technologists
bennuttall
 
PDF
これから Raspberry Pi をいじる方向けの資料 20130616版
Michiya Tominaga
 
Raspberry Pi + Python
Daker Fernandes
 
Iphoneで良い音楽を聞く方法
Kyohei Morimoto
 
How I Learned To Stop Worrying (And Love The KiCad)
ChrisGammell
 
ビル・ゲイツ「学校では教えてくれない人生に役立つ11のルール」
Courslide
 
AKIBAX2010 新ブーム「電子工作」を体験しよう!
encafe
 
これからの音楽はハイレゾだ!
Courslide
 
Why (and how) to switch to KiCad
Baoshi Zhu
 
Designing with KiCAD of 64-bit ARM board
Olimex Bulgaria
 
Raspberry Pi - Lecture 5 Python for Raspberry Pi
Mohamed Abdallah
 
Picademy 5 Picamera Intro Workshop
bennuttall
 
Raspberry PiのUSB OTGを試す
Kenichiro MATOHARA
 
Building the Internet of Things with Raspberry Pi
Neil Broers
 
技適なBluetooth GNSS/GPSレシーバーをRaspberryPiで作りたい
Kenichiro MATOHARA
 
プログラミング言語の理念いろいろ
Tomoki Suzuki
 
Raspberry Piで 初心者が 半日でできる電子工作 を考えてみた
VirtualTech Japan Inc./Begi.net Inc.
 
Picademy #3 Python Picamera GPIO Workshop
bennuttall
 
Raspberry Pi Zero
Baoshi Zhu
 
Raspberry-Pi
Rehan Fazal
 
Hands on Raspberry Pi - Creative Technologists
bennuttall
 
これから Raspberry Pi をいじる方向けの資料 20130616版
Michiya Tominaga
 
Ad

Similar to Physical computing with Python and Raspberry Pi (20)

PDF
Physical Computing With the Raspberry Pi
All Things Open
 
PPTX
Introduction To Raspberry Pi with Simple GPIO pin Control
Pradip Bhandari
 
PPTX
Raspberry Pi Introductory Lecture
Syed Umaid Ahmed
 
PPTX
Raspberry pi
Pravesh Sahu
 
PPTX
Getting Started with Raspberry Pi
yeokm1
 
PDF
Intoduction to physical computing using Raspberry Pi, 18-02-2016
Sebin Benjamin
 
PPTX
An introduction to raspberry pi
kajal sharma
 
PPTX
Python-in-Embedded-systems.pptx
TuynLCh
 
PDF
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
RICELEEIO
 
PDF
My presentation raspberry pi
HusainBhaldar21
 
PDF
Raspberry pi history, tips and use case (coscup19)
Masafumi Ohta
 
ODP
Introduction to Raspberry Pi and GPIO
Kris Findlay
 
PPTX
Raspberry Pi Session - 22_11_2014
Mandeesh Singh
 
PPTX
Raspberry pi basics
BHAWESH RAJPAL
 
PDF
Raspberry pi history, tips and use case
Masafumi Ohta
 
PDF
Hadoop on raspberry pi PART 1
Aniket Maithani
 
PPTX
Not so hard hardware
richardgault
 
PDF
Intro to the raspberry pi board
Thierry Gayet
 
PPTX
Lecture 8
vishal choudhary
 
PDF
Introduction to Raspberry Pi
Isuru Jayarathne
 
Physical Computing With the Raspberry Pi
All Things Open
 
Introduction To Raspberry Pi with Simple GPIO pin Control
Pradip Bhandari
 
Raspberry Pi Introductory Lecture
Syed Umaid Ahmed
 
Raspberry pi
Pravesh Sahu
 
Getting Started with Raspberry Pi
yeokm1
 
Intoduction to physical computing using Raspberry Pi, 18-02-2016
Sebin Benjamin
 
An introduction to raspberry pi
kajal sharma
 
Python-in-Embedded-systems.pptx
TuynLCh
 
Raspberry Pi GPIO Tutorial - Make Your Own Game Console
RICELEEIO
 
My presentation raspberry pi
HusainBhaldar21
 
Raspberry pi history, tips and use case (coscup19)
Masafumi Ohta
 
Introduction to Raspberry Pi and GPIO
Kris Findlay
 
Raspberry Pi Session - 22_11_2014
Mandeesh Singh
 
Raspberry pi basics
BHAWESH RAJPAL
 
Raspberry pi history, tips and use case
Masafumi Ohta
 
Hadoop on raspberry pi PART 1
Aniket Maithani
 
Not so hard hardware
richardgault
 
Intro to the raspberry pi board
Thierry Gayet
 
Lecture 8
vishal choudhary
 
Introduction to Raspberry Pi
Isuru Jayarathne
 
Ad

More from bennuttall (20)

PDF
Raspberry Pi Foundation - Intro for Creative Technologists
bennuttall
 
PDF
Build your product around the best supported mini computer in the world - Ras...
bennuttall
 
PDF
Picademy - Python picamera workshop
bennuttall
 
PDF
Raspberry Pi - background of Raspberry Pi Foundation for Creative Technologists
bennuttall
 
PDF
Ben Nuttall - Creative Technologists Pecha Kucha
bennuttall
 
PDF
Raspberry Pi for startups - Estonia
bennuttall
 
PDF
Raspberry Pi - Estonia
bennuttall
 
PDF
How Raspberry Pi (an educational charity) funds itself without ratlling a tin...
bennuttall
 
PDF
Creative technologists
bennuttall
 
PDF
Raspberry Pi in education - Barcamp Manchester
bennuttall
 
PDF
Raspberry Pi in science education - IMA NW
bennuttall
 
PDF
Pioneering the future of computing education - PyCon Ireland
bennuttall
 
PDF
PyPi (not that one) [Python on Pi] - PyConUK 2014
bennuttall
 
PDF
Raspberry Pi - Denver Hackspaces
bennuttall
 
PDF
St Louis St. John Vianney High School - Raspberry Pi
bennuttall
 
PDF
Arch Reactor - Raspberry Pi
bennuttall
 
PDF
LVL1 - Raspberry Pi
bennuttall
 
PDF
Fayette Academy - Raspberry Pi
bennuttall
 
PDF
RL Young Elementary School - Raspberry Pi
bennuttall
 
PDF
Raspberry Pi - Red Bank Middle School
bennuttall
 
Raspberry Pi Foundation - Intro for Creative Technologists
bennuttall
 
Build your product around the best supported mini computer in the world - Ras...
bennuttall
 
Picademy - Python picamera workshop
bennuttall
 
Raspberry Pi - background of Raspberry Pi Foundation for Creative Technologists
bennuttall
 
Ben Nuttall - Creative Technologists Pecha Kucha
bennuttall
 
Raspberry Pi for startups - Estonia
bennuttall
 
Raspberry Pi - Estonia
bennuttall
 
How Raspberry Pi (an educational charity) funds itself without ratlling a tin...
bennuttall
 
Creative technologists
bennuttall
 
Raspberry Pi in education - Barcamp Manchester
bennuttall
 
Raspberry Pi in science education - IMA NW
bennuttall
 
Pioneering the future of computing education - PyCon Ireland
bennuttall
 
PyPi (not that one) [Python on Pi] - PyConUK 2014
bennuttall
 
Raspberry Pi - Denver Hackspaces
bennuttall
 
St Louis St. John Vianney High School - Raspberry Pi
bennuttall
 
Arch Reactor - Raspberry Pi
bennuttall
 
LVL1 - Raspberry Pi
bennuttall
 
Fayette Academy - Raspberry Pi
bennuttall
 
RL Young Elementary School - Raspberry Pi
bennuttall
 
Raspberry Pi - Red Bank Middle School
bennuttall
 

Recently uploaded (20)

PPTX
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
PDF
I3PM Industry Case Study Siemens on Strategic and Value-Oriented IP Management
MIPLM
 
PDF
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
PPTX
PLANNING FOR EMERGENCY AND DISASTER MANAGEMENT ppt.pptx
PRADEEP ABOTHU
 
PDF
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
PPTX
Building Powerful Agentic AI with Google ADK, MCP, RAG, and Ollama.pptx
Tamanna36
 
PPTX
ENGLISH 8 REVISED K-12 CURRICULUM QUARTER 1 WEEK 1
LeomarrYsraelArzadon
 
PDF
Indian National movement PPT by Simanchala Sarab, Covering The INC(Formation,...
Simanchala Sarab, BABed(ITEP Secondary stage) in History student at GNDU Amritsar
 
PDF
Quiz Night Live May 2025 - Intra Pragya Online General Quiz
Pragya - UEM Kolkata Quiz Club
 
PDF
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
PPTX
grade 8 week 2 ict.pptx. matatag grade 7
VanessaTaberlo
 
PDF
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
PPTX
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
PDF
I3PM Case study smart parking 2025 with uptoIP® and ABP
MIPLM
 
PDF
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
PDF
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
PDF
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
PPTX
MATH 8 QUARTER 1 WEEK 1 LESSON 2 PRESENTATION
JohnGuillerNestalBah1
 
PPTX
Connecting Linear and Angular Quantities in Human Movement.pptx
AngeliqueTolentinoDe
 
PPTX
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 
How to Configure Refusal of Applicants in Odoo 18 Recruitment
Celine George
 
I3PM Industry Case Study Siemens on Strategic and Value-Oriented IP Management
MIPLM
 
WATERSHED MANAGEMENT CASE STUDIES - ULUGURU MOUNTAINS AND ARVARI RIVERpdf
Ar.Asna
 
PLANNING FOR EMERGENCY AND DISASTER MANAGEMENT ppt.pptx
PRADEEP ABOTHU
 
AI-assisted IP-Design lecture from the MIPLM 2025
MIPLM
 
Building Powerful Agentic AI with Google ADK, MCP, RAG, and Ollama.pptx
Tamanna36
 
ENGLISH 8 REVISED K-12 CURRICULUM QUARTER 1 WEEK 1
LeomarrYsraelArzadon
 
Indian National movement PPT by Simanchala Sarab, Covering The INC(Formation,...
Simanchala Sarab, BABed(ITEP Secondary stage) in History student at GNDU Amritsar
 
Quiz Night Live May 2025 - Intra Pragya Online General Quiz
Pragya - UEM Kolkata Quiz Club
 
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
grade 8 week 2 ict.pptx. matatag grade 7
VanessaTaberlo
 
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
I3PM Case study smart parking 2025 with uptoIP® and ABP
MIPLM
 
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
MATH 8 QUARTER 1 WEEK 1 LESSON 2 PRESENTATION
JohnGuillerNestalBah1
 
Connecting Linear and Angular Quantities in Human Movement.pptx
AngeliqueTolentinoDe
 
How to Configure Taxes in Company Currency in Odoo 18 Accounting
Celine George
 

Physical computing with Python and Raspberry Pi