Following on from my last blog post where I used a simple touch sensor to trigger a robot moving, controlled by the Raspberry Pi, I thought we would try something a bit more complex this time. This time we have used three lego touch sensors for buttons, and three of the digital outputs to drive three different coloured LEDs. Putting it all together, with a bit of fun lego construction, we were able to create a simple simon memory game!
This time rather than using Scratch to control it, we went for Python, and we used some code provided on the piface web site to control the game itself.
Unfortunately I only had three different coloured LEDs handy, so our simple simon game only has three buttons rather than the traditional four, but it is still lots of fun! We had to tweak the code to make sure it worked with three inputs rather than four (instructions on the piface page above).
The LEDs were inserted into some clear lego blocks which glow nicely when they are lit up. Simple jumper wires were used to connect the LEDs to a breadboard, and from there to the outputs on the PiFace digital card. Two of the LEDs ran on 5v (which is what the Pi outputs), with the third needing a resistor to bring the voltage down:
Then, we pulled down the code, tweaked the number of inputs, ran it, and tested our memory!
I did look into adding some sounds to make it more authentic, but ran out of time – maybe next time…