In a previous post I talked about a simple method of controlling Lego motors using a raspberry Pi with the PiFace digital card. I decided to see if I could extend this slightly to include some inputs so we can control our Lego creations (with a bit of help from my kids of course!).
After some investigations I came across some great little touch sensors, which you can get for less than a pound each using sellers on bricklink. I also took the opportunity to get some more wires too, with yellow connector blocks on the end so I can easily tell my inputs apart from my outputs.
Getting them working was as simple as wiring the connector block wires into the input screw terminals on the PiFace card.
Now we just needed a fun project to try it out. We decided to create a simple game with a marble and a robot who talks when you get the marble into the goal. The touch sensors are quite sensitive, but we did struggle with a design which registered the marble reliably when it rolled into the goal. In the end we built a platform which pivoted, so any small weight on the platform would push the touch sensor quite firmly, and trigger the input into the Raspberry Pi.
All that was left then was to create the robot’s head to go on top of the goal and “talk” when the marble is successfully rolled into the goal. The motor controlling the robot’s mouth is connected to the output on the PiFace card (in the same way as I described in my previous post).
And here is a video of it in action: