Skip to main content

Controlling 'junk' robot - three options



Three approaches to control it will be considered here:
- via Raspberry Pi;
- via Micro:Bit
-via Crumble controller

1. Raspberry Pi based

In this Raspberry Pi based Junkbot design a combination of Python and Pimoroni's Explorer HAT PRO are used to control it. Explorer HAT Pro is a good choice, it can control two motors with a library provided to simplify the programming. For this the Junkbot was the one shown above: a drinks can, pen, LEGO bits, motor and broken propellor.

Before the Explorer HAT can be used the library needs to be installed via the Terminal and the instructions below

curl get.pimoroni.com/explorerhat | bash

Python code to control the junkbot is shown below.


import explorerhat
from time import sleep

def spin1(duration):
    explorerhat.motor.one.forward(100)
    sleep(duration)
    explorerhat.motor.one.stop()

def spin2(duration):
    explorerhat.motor.one.backward(100)
    sleep(duration)


    explorerhat.motor.one.stop()


2. Micro:bit
what about the recently released Micro:Bits; can it be used to control a junkbot?










2.2 Approach used in the project.
A Micro:Bit was selected for two reasons. First, there was been a BBC supported project to give year 7 (or equivalent) students a Micro:bit (http://www.bbc.co.uk/programmes/articles/4hVG2Br1W1LKCmw8nSm9WnQ/the-bbc-micro-bit), so they are available in the schools. Secondly, 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 ). Using Micropython via the online editor https://www.microbit.co.uk to program the board and therefore the junkbot connected. The board with the Micro:Bit attached can be seen in the figure above carried on 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()

2.3 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

3. Crumble



Lastly a Crumble controller from Redfern Electronics is used. The crumble controller is an excellent board for this project, it is relatively cheap, it is programmable with it's own graphical language, and it has motor drivers built in. In the figure to the left the parts (apart from adhesive tape) used can be seen.


3.1. Wiring up
Using croc-clips ideally, but loops of wire if not, connect the battery to the controller and also the motors to the controller. Plug in the USB cable into the controller and the computer.

3.2. Running and Controlling
Make sure the Crumble software (http://redfernelectronics.co.uk/crumble/) is installed on the computer. 

An example is shown below that drives the motor forward and then backward repeatly. You might need to change the percentage values based on experiment, for the motor used. In the video below the junkbot is shown in action.











Related Links



All views and opinions are the author's and do not necessarily reflected those of any organisation they are associated with. Twitter: @scottturneruon


If you would like to know more about the Junkbots project contact scott.turner@northampton.ac.uk

Comments

Popular posts from this blog

junkbots 3 - bring it all together

Junkbots session 3: Move the robot but now there are rocks in the way.  This is the last of three posts - Introduction and sequence - Loops and just having fun - This one: Making decisions and bringing it all together. What is the Junkbots project The Junkbots project has been running for a number of years as an initiative to bring sustainability, computing and engineering together by building bots out of junk; details of the project can be found at.  https://junkbots.blogspot.com/  . Junkbots is an extension of the Research into the teaching problem-solving going on at the University of Northampton please feel to visit  https://computingnorthampton.blogspot.com/2019/01/problem-solving-research-outputs-and.html  for more details.   What are we going to do? ·         Play with a Scratch robot on the screen! ·         Build on the routines from the previous session. ·    ...

Junkbot Raspberry Pi: 3 How to do it

Figure 1 In previous posts I start looked at using ScratchGPIO to control a junkbot  ( http://junkbots.blogspot.com/2014/08/junkbot-pi-1-scratchgpio.html ) and showed a Pi controlled junkbot briefly in action ( http://junkbots.blogspot.co.uk/2014/08/junkbot-raspberry-pi-2-raspberry-pi.html ). In this post I aim to discuss - Choice of motor controller card - Provide an example of a drawing junkbot controlled through Scratch and Raspberrry Pi Choice of interface/Controller card The card choosen was the 4Tronix PiRoCon card  ( http://4tronix.co.uk/store/index.php?rt=product/product&product_id=182 ). Selected for four reasons - Price is reasonable (in my opinion). - Fits straight onto the Pi through the GPIO - no extra cables needed. - ScratchGPIO has it as an addon so it makes programming it even easier (see http://cymplecy.wordpress.com/2013/10/31/pirocon-from-4tronix/ ). - Others are using it for robot projects. Use it is quite easy plug the board directl...

Brooke Weston Event

Students at Brooke Weston School, Corby have been working with the University of Northampton's School of Science and Technology on the junkbots project. Scott Turner and Terry Tudor on the 16th and 17th February 2010 went to the school to run the sessions. Starting with a talk and activities on waste management, including how much waste the UK produced, and in terms of numbers of slices of toast what is the cost of energy of leaving a monitor on overnight.   The task was to produce robots out of rubbish that could carry other rubbish into a containment area. The change made to the sessions was that students brought there own 'junk' to the sessions. S ome innovative and creative designs were produced involving 'legs', wheels (including turning cans into wheels and wheels from old toys).    Some of the designs pushed rubbish into the area, but one of the designs carried the rubbish into the area and some designs used magnets to pick up small steel parts (nuts a...