Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Teach, Learn and Make with Raspberry Pi - Estonia seminar

Ben Nuttall
September 08, 2015

Teach, Learn and Make with Raspberry Pi - Estonia seminar

Exploring teaching computing and informatics through physical computing with the Raspberry Pi

Ben Nuttall

September 08, 2015
Tweet

More Decks by Ben Nuttall

Other Decks in Education

Transcript

  1. Teach, Learn and Make
    with Raspberry Pi
    Ben Nuttall
    Raspberry Pi Foundation
    UK Charity 1129409

    View full-size slide

  2. 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)

    View full-size slide

  3. Ben Nuttall

    Education Developer Advocate
    at the Raspberry Pi Foundation
    – Software & project development
    – Learning resources & teacher
    training
    – Outreach

    Hobbyist turned employee

    Based in Cambridge, UK

    @ben_nuttall on Twitter

    View full-size slide

  4. Raspberry Pi

    Sonic Pi

    Python

    Physical computing

    Minecraft: Pi Edition

    Picamera

    Astro Pi

    View full-size slide

  5. Sonic Pi

    Sound synthesiser for creating
    music

    Audible computing

    Uses simple syntax text-based
    programming language Ruby

    Used for compositions and live
    coding performances

    Introduce computing concepts
    through music

    Created especially for education

    View full-size slide

  6. Python

    Powerful extensible
    programming language

    Easy to read and write

    Make software, games, GUIs,
    websites, robots and more

    Ideal for physical computing

    Extensive library of additional
    modules for Raspberry Pi
    hardware

    Recommended for education

    View full-size slide

  7. Physical computing

    Flashy lights

    Motors & robots

    Photo & video

    Sensors

    Internet of Things

    Engaging and empowering

    View full-size slide

  8. 3V3 = always on

    View full-size slide

  9. GPIO = user controllable

    View full-size slide

  10. Flash LED with Python
    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)

    View full-size slide

  11. Traffic Lights
    from RPi import GPIO
    from time import sleep
    GPIO.setmode(GPIO.BCM)
    red = 9
    yellow = 10
    green = 11
    leds = [red, yellow, green]
    for led in leds:
    GPIO.setup(led, GPIO.OUT)
    GPIO.output(green, True)
    GPIO.output(yellow, False)
    GPIO.output(red, False)

    View full-size slide

  12. Traffic Lights
    while True:
    sleep(10)
    GPIO.output(green, False)
    GPIO.output(yellow, True)
    sleep(1)
    GPIO.output(yellow, False)
    GPIO.output(red, True)
    sleep(10)
    GPIO.output(yellow, True)
    sleep(1)
    GPIO.output(green, True)
    GPIO.output(yellow, False)
    GPIO.output(red, False)

    View full-size slide

  13. An alternative approach
    class LED(object):
    def __init__(self, pin):
    self.pin = pin
    GPIO.setup(pin, GPIO.OUT)
    def on(self):
    GPIO.output(self.pin, True)
    def off(self):
    GPIO.output(self.pin, False)
    red = LED(9)
    yellow = LED(10)
    green = LED(11)

    View full-size slide

  14. An alternative approach
    green.on()
    yellow.off()
    red.off()
    while True:
    sleep(10)
    green.off()
    yellow.on()
    sleep(1)
    yellow.off()
    red.on()
    sleep(10)
    yellow.on()
    sleep(1)
    green.on()
    yellow.off()
    red.off()

    View full-size slide

  15. Traffic Lights
    green.on()
    yellow.off()
    red.off()
    sleep(10)

    View full-size slide

  16. Traffic Lights
    green.off()
    yellow.on()
    sleep(1)

    View full-size slide

  17. Traffic Lights
    yellow.off()
    red.on()
    sleep(10)

    View full-size slide

  18. Traffic Lights
    yellow.on()
    sleep(1)

    View full-size slide

  19. Traffic Lights
    green.on()
    yellow.off()
    red.off()

    View full-size slide

  20. Minecraft: Pi Edition

    Free version of Minecraft on
    Raspberry Pi

    Python programming
    interface

    Learn Python by building
    things and making games in
    Minecraft

    Creative computing

    View full-size slide

  21. Flowers
    from mcpi.minecraft import Minecraft
    from time import sleep
    mc = Minecraft.create()
    flower = 38
    while True:
    x, y, z = mc.player.getPos()
    mc.setBlock(x, y, z, flower)
    sleep(0.1)

    View full-size slide

  22. Planting flowers
    grass = 2
    flower = 38
    while True:
    x, y, z = mc.player.getPos() # player position (x, y, z)
    block_beneath = mc.getBlock(x, y­1, z) # block ID
    if block_beneath == grass:
    mc.setBlock(x, y, z, flower)
    else:
    mc.setBlock(x, y­1, z, grass)
    sleep(0.1)

    View full-size slide

  23. Picamera

    Official Raspberry Pi camera
    module

    Command line interface for
    basic use

    Python programming
    interface for projects

    Still pictures, video, time-
    lapse

    View full-size slide

  24. Camera preview

    Open Terminal window

    raspistill -k

    View full-size slide

  25. Python – take a selfie
    from picamera import PiCamera
    from time import sleep
    with picamera.PiCamera() as camera:
    camera.start_preview()
    sleep(5)
    camera.capture('/home/pi/image.jpg')
    camera.stop_preview()

    View full-size slide

  26. Python – stop motion
    with picamera.PiCamera() as camera:
    camera.start_preview()
    frame = 1
    while True:
    next = input('Press Enter to continue...')
    camera.capture('/home/pi/animation/frame%03d.jpg' % frame)
    frame += 1

    View full-size slide

  27. Sense HAT

    8x8 RGB LED matrix

    Mini joystick

    Gyroscope

    Accelerometer

    Magnetometer

    Temperature sensor

    Barometric pressure sensor

    Humidity sensor

    View full-size slide

  28. Sense HAT - Python
    from sense_hat import SenseHat
    sense = SenseHat()
    sense.show_message('Hello world!')

    View full-size slide

  29. More examples
    https://github.com/RPi­Distro/python­sense­
    hat/tree/master/examples
    https://github.com/bennuttall/sense­hat­examples

    View full-size slide

  30. Resources
    https://www.raspberrypi.org/resources/

    View full-size slide

  31. Teach, Learn and Make
    with Raspberry Pi
    Ben Nuttall
    Raspberry Pi Foundation
    UK Charity 1129409

    View full-size slide