Saturday, 21 March 2015

Hacking into Minecraft on the Raspberry Pi. Using real fruit!

Many people buy a Raspberry Pi and it sits on a shelf for a while before they look into what to do with it. This is changing rapidly with the introduction of Computing on the National Curriculum and the Governments proposal to give a Raspberry Pi to every Year 7 in September 2015:


One of the most engaging experiments I've personally seen in action (and tried and tested on our recent open day at Scarborough College) is using a capacitive touch sensor to run programs on the Raspberry Pi. When coupled with Minecraft, this is the result:



The idea came from a post I saw by "Arghbox" on his blog which is well worth looking at:


He used an Adafruit capacitive touch sensor to control certain functions in Minecraft through the Raspberry Pi. I thought this was a really nice idea to engage students in some programming and electronics using a game they could all relate with, so I did my own. Adapting some of Martin O'Hanlon's ideas I made my own python programme to make it a bit more visual for our open day.

This is my version of the code: I used a real flower to place a flower in Minecraft and used the properties of graphite as a conductor to write a word which, when touched, triggered the sensor. I also used a piece of code which took a picture using the Raspberry Pi Camera when you touched the Orange. Another feature which I forgot to put on the video was that one sensor was placed in a bowl of water, so when you dipped a finger in it, an area on Minecraft was cleared out.

Here's the code, shared on Google drive:
capacitive2.py

You may get a warning saying it is not safe to download as it is an executable python script, but please be assured that it is OK.

Without repeating here what someone else has put a lot of work into, please follow the instructions here by Craig Richardson on how to wire up you Raspberry Pi and Capacitive touch sensor. I followed them to the letter and as you can see from the video above. It worked really well.

https://learn.adafruit.com/capacitive-touch-sensors-on-the-raspberry-pi

I did something else with the pictures I took on the open day using the touch capacitor...coming in my next post :)

No comments:

Post a Comment