Introduction: DIY Minecraft Pickaxe Controller
I'd had the parts laying around to make this for nearly a year and finally had the time to get down to it. What we have here is a USB game controller (HID) that plugs straight into any machine with USB and acts as a keyboard/mouse/joystick.
It's got an accelerometer which acts as 2 axis, tilting in any direction can be mapped to movement keys, any keyboard key actually as well as impersonating a mouse or joystick. It's also got programmed in a swing detector so a quick flick forward also acts as a mappable keypress/mousebutton/movement.
Aside from the tilt sensors it's got a 2 axis thumbstick and 2 push buttons.
The required materials are pretty cheap, I made the pickaxe itself out of 4 sheets of 5mm thick EVA foam which works a treat (it's that same foam that cosplayers like to use for their elf armour). I did the first prototype with 4 layers of thick cardboard and that worked pretty good too so theres a few options there.
For the electronics I've got
- Arduino Pro Micro (has to be a Pro Micro or a microcontroller with the 32U4 as it can do the HID magic that the normal Arduino can't. amazon link
- ADXL345 3 axis Accelerometer amazon link
- 2 x push buttons amazon link
- A PSP style thumbstick amazon link
Note: I didn't actually buy from any of those Amazon links so can't attest to how good the sellers are, links are just to show the specific devices.
A lot of these have pretty common replacement options, the buttons are just buttons, there are a bunch of thumbstick options that work the exact same way and there's heaps of accelerometers that are just as easy to stick in there. These are what I used though
Aside from that I used PVA glue to glue the layers together, hot glue to stick the components in position, a bunch of little wires to connect everything and some acrylic paints to paint it in the end.
Oh, I hot glued a USB cable in there permanently as well so I didn't risk breaking off that little connector on the Arduino Pro Micro constantly plugging it in and out.
Step 1: Cutting the Foam
^^ All this can be seen in action in the video up top ^^
First I worked out how big I wanted the whole thing to be, I settled on a size that gave me a 2cm square grid. The foam sheet I'm using is 5mm thick so 4 layers gives me 2cm height as well. That's great as it gives me 2 outer layers I can paint and 2 inner layers I can cut up and hide electronics in to my hearts content.
I did make one by drawing out a grid and cutting by hand as above, I actually made the parts to make 40 of these for the students I teach so the final version was laser cut. The black foam is the exact same stuff as the white, just a different colour which I picked because it looks cool and if the laser is cutting it I don't have to mark it for cutting.
Here is the dxf file that I used with my laser cutter. I can't stress enough though, this looked great being done by hand and even with cardboard instead of the EVA foam, I picked foam and laser because I had to make a lot of them.
In any case, I cut 4 layers and glued them together in 2 pairs with PVA glue.
Then with one of the pairs i laid out all the components where I wanted them and sliced away one of the layers of foam to fit them in.
With the PVA left to dry for about 20 minutes it was gummy enough to hold the 2 layers in place but not so dry that it was hard to pull the sliced pieces out.
NOTE: I'm not actually gluing the components in at this point, we'll use hot glue for that later. I just put them in place temporarily to make sure everything fit. The white PVA glue is just to hold the 2 foam layers together.
The second pair of foam layers doesn't need this much work, I just had to slice out a little for the thumbstick and the buttons which were too big to fit in that single layer space. The microcontroller, accelerometer and wires will all fit happily in this half.
Step 2: Wiring It All Up
I measure out and stripped the ends of wires and soldered them in as in the above diagram.
The accelerometer is an I2C device so it's SDA pad must be wired to the SDA pin on the Arduino Pro Micro, which is digital pin 2 and the SCL pin is digital pin 3.
The other connections aside from the 5v and GND connections are more flexible, the buttons are attached to any digital pin, I'm using the internal pullups of the microcontroller so we don't need any additional components there. The 2 axis for the thumbstick are connected to the Analog 0 and 1 pins.
The next step once everything is connected is to slather it all liberally with hot glue, not a bad idea to test all the connections first. There is a variable called TESTMODE at the top of the firmware which will prevent sending any keypresses and will instead just send the current state of every input over serial so it can all be checked in the Arduino serial monitor.
If everything is good, cover the whole lot in hot glue, the buttons and thumbstick especially will see a bit of abuse so best to lock them in tight.
Step 3: Painting
So next I used PVA glue to stick the pair of foam sheets with the electronics to the opposite pair, being careful not to get any glue in the workings of the buttons or thumbstick.
I then sandwiched them together and left something heavy on them overnight to let the glue dry. The PVA glue won't actually dry all the way through in that time so it wouldn't hurt to leave it longer if you have the patience, but it should be stuck strongly enough after 24 hours that it won't come apart unless you're particularly uncareful.I gave it a really thin coat of PVA on the outside as the foam is like a sponge and needs sealing otherwise I'd need to do several coats of paints. I actually gave it three coats of PVA like this, it stiffened up the foam a little as well. Then I grabbed some cheapo acrylic paints and got to painting little squares. I didn't match this to the actual Minecraft colours, I just picked what looked good to me at the time. I only did one coat of actual paint, it could have used another but I was well over it by then :-D
Step 4: Deploying the Firmware and Keymapper
The code I used for the microcontroller uses the Keyboard.h and Mouse.h libraries which come with the Arduino IDE, I used an Adafruit library to talk to the accelerometer.
The code to send keypresses is actually very simple, just Keyboard.press('h') and Keyboard.release('h') to press and release the 'h' key for example. My code got overly complicated because I wanted each control to be easily remappable for mouse buttons, axis movement as well as keyboard buttons. By default none of the keys will be mapped to anything, the keymapper program will have to be run first, after that the pickaxe will keep it's configuration on board.
Here is the pickaxe firmware.
The remapper is basic but fairly simple.
Press the number key on the keyboard that matches the correct serial port for the pickaxe. This assumes you've already uploaded the firmware of course.
Set all the keys you want and then press apply, simple as that! Whenever you use the remapper again it will grab all the current key mappings from the pickaxe so you won't have to start again.
At this point it should already be sending keypresses so you can go and play whatever you like. Once again, watch the video at the start to see it in action.