Hatherly.com

Blog



More Lego Raspberry Pi and Scratch fun – adding some inputs

Posted on September 21, 2014 by Adam under RaspberryPi

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.
21-09-2014 13-47-18_0004_small

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.
21-09-2014 13-57-07_0007_small

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).
21-09-2014 13-47-39_0005_small

Finally, a nice simple scratch script to make it all work, and to keep score!
MarbleRobotScript

And here is a video of it in action:



  |  3 Comments


3 Comments:


laura on September 22, 2014

well done daddy!!!

laura on September 22, 2014

I helped daddy a bit too!!!!!!

Jack Bloxwich on October 22, 2015

Wow! This is so amazing! I`d like to see more awesome builds similar to this one!




Leave a Comment