Hacking a Toy Crane for Micro:bit Control

by kitronik in Circuits > Microcontrollers

4462 Views, 18 Favorites, 0 Comments

Hacking a Toy Crane for Micro:bit Control

bett_show_2016_kitronik_stand.jpg
bbc_microbit_powered_crane_built_1000.jpg
bbc_microbit_powered crane_tilt to control_crane graphic_1000.jpg
bbc_microbit_powered_crane_parts_1000.jpg

In this step by step guide we'll take you through customising a toy crane so that it can be controlled with a BBC micro:bit, using the Kitronik Motor Driver Board for the BBC micro:bit and the BBC micro:bit's built-in accelerometer to detect tilt and turn motions.

Using the accelerometer in the BBC micro:bit to detect in which direction it is being tilted (x or y axis) we can feed that information back to the motors within the crane. If the BBC micro:bit is held flat with the LEDs facing upwards it will read X and Y as zero: X and Y become larger or smaller (negative), depending on in which direction it is tilted.

Learn how to:

  • Code the BBC micro:bit to control a crane via the built-in accelerometer.
  • Convert a toy crane into a BBC micro:bit controlled crane.

Parts List:

To customise the crane you will need the following electronic components:

For the casing options for the controller you can either use our laser cut template:

Or alternatively for an off the shelf solution:

You will also require the following equipment:

Build the Crane

bbc_microbit_powered_crane_step_1_1000.jpg

Build the toy crane as described in the instructions that are supplied with it.

Remove the Controller

bbc_microbit_powered crane_step_2_1000.jpg

Remove the supplier controller by cutting the cable. Do this near to the controller to leave as much cable as possible.

Prepare the Wires

bbc_microbit_powered crane_step_3_1000.jpg

Strip away a section of the black insulation and then strip the insulation off the end of each of the four internal wires, leaving the copper internal wire exposed.

Connect the Wires

bbc_microbit_powered crane_step_4_1000.jpg

Connect the blue and yellow wire to the ‘Motor 1’ input on the Kitronik Motor Driver board and the red and white wire into the ‘Motor 2’ input.

Connect the Power

bbc_microbit_powered crane_step_5_1000.jpg

Insert the batteries into the battery holder and connect it to the power terminal on the Motor Driver Board for the BBC micro:bit. The battery pack has an on/off switch to turn on the power.

Write the Code

code.jpg

Program a BBC micro:bit with the crane control program. You can download the code from this address: https://www.microbit.co.uk/dzlocb.

Now, let’s try the code out! Press compile* and after a few moments the code should appear as a download in your browser. If you plug your BBC micro:bit into a USB port it will show up as a storage device. Simply drag and drop the .hex file you just downloaded onto the BBC micro:bit. The file might not show up on the BBC micro:bit in the file explorer but it is there! Once the file has been transferred (the light on the BBC micro:bit will stop blinking rapidly) remove the BBC micro:bit from your computer.

Test the Code

bbc_microbit_powered crane_step_6_1000.jpg

Insert your coded BBC micro:bit into the connector on the Kitronik Motor Driver board and tilt the Motor Driver Board to try it out!

Casing (Optional)

bbc_microbit_powered_crane_built_1000.jpg

We housed our BBC micro:bit in a simple laser cut case but there are many suitable casing options or it could be used without one at all. You can download a zipped copy of the .dxf files here.

Customise an Existing Enclosure

bbc_microbit_powered crane_casing_1000.jpg
bbc_microbit_powered_crane_marking_1000.jpg
bbc_microbit_powered_crane_hammond_box_wire_1000.jpg
bbc_microbit_powered_crane_screwing_mounting_holes_1000.jpg
bbc_micobit_powered_crane_box_contents_1000.jpg

In this example we used a Hammond Blue Translucent Box 193mm x 113mm x 61mm as a case.

Simply drill 5 holes in the box (4 in the side of the box for mounting the Motor Driver Board for the BBC micro:bit on to the side of the box) and one hole for inserting the wire from the crane. Mark the five holes using a whiteboard pen on the outside of the box so you know where to drill. Make sure the hole for the wire is on a different side of the box than to where you are mounting the Motor Driver Board for the BBC micro:bit.

Next, push the wire through the hole you have made in the middle of the box so you can screw the wires into the Motor Driver Board for the BBC micro:bit.

Mount the Motor Driver Board for the BBC micro:bit on the side of the box using 8mm Plastic Spacers and 6mm M3 Machine Screws.

Connect the battery box, and plug in the BBC micro:bit and away you go!