Tuesday, 19 April 2016

Controlling Minecraft with SAM Labs Electronics


My kids thought it was great fun to be able to control Minecraft using physical electronics components. SAM Labs is a range of modular wireless electronics components that are easy to use in fun tech projects. With the new SAM Labs software you can trigger virtual keypresses and mouse events so of course we had to hook SAM Labs up to Minecraft.

In this article we'll look at the basics of controlling SAM Labs in Minecraft, our next project is more advanced (and lots of fun!)


If you haven't come across SAM Labs before then start with our other articles:
If you want to understand more about Minecraft then try our getting started with Minecraft article.

      You'll Need

      You can adapt this project to whatever SAM Labs input modules you have, we used:
      • Tilt Sensor - great for sword or pickaxe movement
      • Button - works well for placing blocks
      • Slider - great for looking left and right
      You'll also need the bluetooth dongle that came with your SAM Labs set. 

      If you don't already have a set then we'd recommend the SAM Labs Make Kit for projects like this because it includes two buttons, a tilt sensors and a slider plus other components that you can use in different projects.

      Update: Now there's the new SAM Labs Curious Kit which includes a tilt switch, button and slider as well as 2 motors and an RGB Led as well as components for making cool projects that will appeal to a similar age group.

      You'll need the SAM Labs software installed. And of course you'll need Minecraft installed.

      Optionally you can also add a toy Minecraft pick or sword and toy Minecraft blocks.

      Set Up


      This project is really easy to set up in SAM Labs. The finished project will look like this:



      1. Turn on your SAMs and they should appear in the Live SAMs area. Drag them onto the workspace.
      2. Connect the Tilt sensor SAM to a Control Cursor app and make sure the left mouse button is selected. This will send a left mouse button click when the tilt sensor is tilted.
        The tilt sensor sends a left-click (mine / attack)


        If you have a toy Minecraft pick or sword then you can attach the tilt sensor to it using sticky tack, we used a 3D printed mini pick and a cardboard sword. 
      3. Connect the Button SAM to a Control Cursor app and this time make sure the right-mouse button is clicked. This will allow you to place blocks and use items in Minecraft.
        The button sends a right-click (place block / action)



        If you have a Minecraft toy block or LEGO pieces then you could attach the SAM Button to a physical block.

        Or you could place the SAM button under a block and then push the block to place! We used blocks from the Minecraft Stop-Motion Animation studio which happened to be just about the right size to conceal a SAM. You can use a bit of sticky tack to temporarily hold the pieces together if you need to.

        Surround the SAM button with blocks
        Pop a block on top of the SAM button. 
      4. Connect the Slider to a Control Cursor app and this time make sure the X Axis setting is selected. This will allow you to look left and right using the slider.
        The slider sends an x-position (look left-right)

      Testing


      Now run Minecraft. You might want to create a new Creative world to try things out in. 

      Make sure you have an item selected in your hotbar. A basic block is fine. Use your SAM button to place blocks. 

      Try out your pick or sword. You might need to adjust the position of the tilt sensor on the pick /sword to make sure it mines / attacks in the down position. 

      Try using the slider switch to turn your view left and right - you might need to turn the SAM upside down to make sure the view moves in the right direction. 

      Verdict

      This project was a lot of fun. It would be a great way to interest a Minecraft fanatic in practical electronics and could lead on to doing more real-world tech projects.

      Kids had lots of fun with this project at the Hacksoton event. 

      If you have another SAM button then you could use that for accessing your inventory or another action you perform regularly. 

      In future projects we'll take a look at more advanced techniques using command blocks.

      More about SAM Labs:
      More about Minecraft:




      More from Tech Age Kids:

      Comments:

      Morten said...

      This is an amazing project!!

      Tracy said...

      And amazingly easy to do with SAM Labs!

      Post a Comment