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. 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)
  2. 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
  3. Raspberry Pi • Sonic Pi • Python • Physical computing

    • Minecraft: Pi Edition • Picamera • Astro Pi
  4. 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
  5. 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
  6. Physical computing • Flashy lights • Motors & robots •

    Photo & video • Sensors • Internet of Things • Engaging and empowering
  7. 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)
  8. 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)
  9. 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)
  10. 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)
  11. 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()
  12. 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
  13. 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)
  14. 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)
  15. Picamera • Official Raspberry Pi camera module • Command line

    interface for basic use • Python programming interface for projects • Still pictures, video, time- lapse
  16. 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()
  17. 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
  18. Sense HAT • 8x8 RGB LED matrix • Mini joystick

    • Gyroscope • Accelerometer • Magnetometer • Temperature sensor • Barometric pressure sensor • Humidity sensor
  19. Sense HAT - Python from sense_hat import SenseHat sense =

    SenseHat() sense.show_message('Hello world!')