Sunday 11 September 2016

How to do it yourself: Microbit Junkbot


What is a Junkbot?
For this project, it is a moving ‘bot’ made from waste materials, combined with an electric motor and a programmable device (in this case a Micro:Bit) to control (or try) it. An example is shown below. More details on junkbots can be found at http://junkbots.blogspot.co.uk/


Stage 1 - The start of a Junkbot
This stage is relatively simple. Tape some pens or straws to a drinks can.




Stage 2 - Physical arrangement of Microbit and motor control board

The control part is this via a Micro:bit (http://www.bbc.co.uk/programmes/articles/4hVG2Br1W1LKCmw8nSm9WnQ/the-bbc-micro-bit). Kitronik produce a motor driver board, and provide quite a bit of support for it, for the Micro:Bit (the latest version of the board can be found at https://www.kitronik.co.uk/5620-motor-driver-board-for-the-bbc-microbit-v2.html ). A 6v battery pack is connected (see on the left of the image) and wires going to a motor are attached to the first block on the front left (marked as motor A).



The overall arrangement is show below, including a broken propellor as an unbalanced load to make the motor vibrate - the propellor was to hand but if you can secure something a clothes peg this could be used.


Stage 3 - Built Junkbot
Now we just need to put them together by taping (or fixing somehow) the motor to the junkbot built in stage 1. A further possibility is to attach the Micro:Bit, motor driver board and battery pack to the junkbots; but this adds weight.








Stage 4 Code
 Using Micropython via the online editor https://www.microbit.co.uk to program the board and therefore the junkbot. 
An example piece of code is shown below:

from microbit import *

def startIt():
   pin8.write_digital(1)
   pin12.write_digital(0)
   pin0.write_digital(1)
   pin16.write_digital(0)    

def leftTurn(duration):
   pin8.write_digital(0)
   pin12.write_digital(1)
   sleep(duration)
   
def stopIt():
   pin8.write_digital(1)
   pin12.write_digital(1)
   sleep(2000)

while True:
   startIt()
   
   if button_a.is_pressed():
       leftTurn(100)
   
   if button_b.is_pressed():
       stopIt()

Unplug the Micro:bit from the motor driver board and download the code to the microbit. Unplug the download cable and plug the Micro:Bit back into the motorboard, with the battery pack attached there is enough power for the Micro:Bit and the motor - don't plug in any other power including the programming cable when it is in the motor driver board.


Stage 5 In action



Suggested Resource List
  • Small Electric Motor
  • Kitronik Motor Board
  • Battery Pack
  • BBC Micro:bit
  • Pens
  • Junk (Can or Bottle)
  • Wires
  • Tape
  • Scissors
  • Broken Propeller or un-balanced load
  • Screw Driver


Related Links






All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with.

No comments:

Post a Comment

ChatGPT, Data Scientist - fitting it a bit

This is a second post about using ChatGPT to do some data analysis. In the first looked at using it to some basic statistics  https://robots...