Tuesday, August 21, 2018

Shakey Shakey - a game using title switches

For the most recent Egham Raspberry Jam @EghamJam we did two workshops.
One was NoPi Blinky, making LEDs blink without any programming. More to come on this as during the workshop we found a few typos.

The other was Shakey Shakey.

For the workshops my goal is to do something slightly different that not only teaches the attendees something new from either a programming or electronics standpoint but also shows them creative options.

Shakey Shakey was based around really simple tilt switches.  They're basically a small tube with a contact inside that moves as you tilt the tube.  Really simple and really cheap. On eBay UK they're about £1.50 for 20. So, ideal when you need a bunch for the Jam
Tilt Switch

The only other things needed then were some female-female jumper wires and some 2 core wire.
I cut the female-female wires in 2 giving me a pair of wires that had the female connectors on one end and bare wire the other.  Cut the 2 core wire into about 150cm lengths and used them to connect the switch to the other wires giving a nice long wire for the kids to shake without (hopefully) unplugging the wires or pulling on the Raspberry Pi.

With the hardware sorted I them did the worksheet which is available to download from GitHub along with other Jam worksheets.

Shakey Shakey worksheet
The worksheet goes through:

  • Connecting a tilt switch
  • Python code to read the switch and display how many times it connects
  • Adding a pause to deal with debouncing
  • Adding a second tilt switch
  • Updating the code so the switches have to be activated alternatively
  • Final update of the code to add a timeline making it into a game

We had a full workshop and the kids who took parts seemed to really enjoy the coding and then playing the new game they created.

At the end I challenged the participants to come back to the next Egham Raspberry Jam (21st October 2018) with their own program that uses the same tilt switch controllers.  The worksheet at the end gives some suggestions.  Here's looking forward to the 21st of October to see what fantastic creative ideas the kids come up with.