Friday, 18 December 2015

Minecraft, a Microbit and an X-Wing

I was having a chat with David Whale, my co-author of Adventures in Minecraft and he remarked that wouldn't it be cool if you could control something in Minecraft using the Microbit. (Btw - you should definitely check out David's virtual Minecraft Microbit.)

I settled on the idea of using the Microbit's accelerometer to control an object flying through Minecraft. What object, well it had to be the X-Wing, from my previous Minecraft - Star Wars project.


The A button starts and stops the X-Wing, by tilting the Microbit left and right you can turn and the B button drops blocks of TNT which create craters where they land.


There are 2 python programs:
  1. microbitreaddata.py - this runs on the Microbit and reads the status of the buttons and accelerometer 
  2. mcfly.py - this runs on your computer (I used a Windows PC running Raspberry Juice and full Minecraft, but it would work on a Raspberry Pi as well) which reads the data from the Microbit and makes all the calls to move the X-Wing in Minecraft.
You will find the full code and my other Microbit MicroPython examples at github.com/martinohanlon/microbit-micropython.

6 comments:

  1. Thanks for that, I might have a go with the Pi and SenseHat

    ReplyDelete
  2. It might be relatively easy to do this with an ESP8266 and send the accelerometer and button data via your android smartphone via an app like RoboRemo. You would just have the ESP8266 send the received commands to its serial port. Or perhaps you could just have RoboRemo connect directly to whatever is hosting Minecraft.

    ReplyDelete
  3. It might be relatively easy to do this with an ESP8266 and send the accelerometer and button data via your android smartphone via an app like RoboRemo. You would just have the ESP8266 send the received commands to its serial port. Or perhaps you could just have RoboRemo connect directly to whatever is hosting Minecraft.

    ReplyDelete
  4. Trying to run it. Do you need to install anything on the pi to get serial to work

    ReplyDelete
  5. Is there an easy way to adapt this for a Mac? Great fan of your book and have everything setup as detailed there.

    ReplyDelete