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

Programming and Electronics with the Raspberry Pi

Matt J Williams
July 19, 2012
17

Programming and Electronics with the Raspberry Pi

Outreach demo for a School of Computer Science & Informatics Open Day event. With Mark Greenwood. July 2012.

Matt J Williams

July 19, 2012
Tweet

Transcript

  1. Programming and
    Electronics with the
    Raspberry Pi
    School of Computer Science & Informatics

    View Slide

  2. What is the Raspberry Pi?

    View Slide

  3. What is the Raspberry Pi?

    View Slide

  4. What is the Raspberry Pi?

    View Slide

  5. =

    View Slide

  6. How much does a Raspberry Pi
    cost?

    View Slide

  7. What are we doing today?

    View Slide

  8. Let's run our first program!

    View Slide

  9. Let's run our first program!

    View Slide

  10. Let's run our first program!

    View Slide

  11. turnOn(1)
    turns on the first light
    turnOn(2)
    turns on the second light
    turnOff(1)
    turns off the first light
    sleep(2.5)
    wait for 2.5 seconds
    What instructions can we use?

    View Slide

  12. Try making your own light patterns!

    View Slide

  13. What about repeating a pattern?

    View Slide

  14. for i in range(5):
    turnOff(2)
    sleep(1.0)
    turnOn(2)
    sleep(1.0)
    What about a repeating pattern?

    View Slide

  15. Try making your own repeating
    patterns!

    View Slide

  16. How can we use the button?

    View Slide

  17. Let's use a new instruction: isPressed()
    while True:
    if isPressed():
    turnOff(1)
    turnOn(2)
    else:
    turnOff(2)
    turnOn(1)
    sleep(0.1)
    How can we use the button?

    View Slide

  18. Try making a pattern that starts
    when you press the button

    View Slide