Saturday 3 September 2016

Miniproject: Micro:bit can now control a junkbot

A new direction has been developed for the junkbot project (http://junkbots.blogspot.co.uk/); previously Raspberry Pis have been used to control the junkbot’s movement (http://robotsandphysicalcomputing.blogspot.co.uk/2016/01/python-junkbot.html) – but what about the recently released Micro:Bits; can it be used to control a junkbot?

Matthew Hole, a student from Wrenn Academy, Northamptonshire ; has been investigating this idea whilst on a Nuffield Research Placement (http://www.nuffieldfoundation.org/nuffield-research-placements) working with Dr Scott Turner, University of Northampton. The project was to look into developing junkbots controlled using a Micro:bit and also to produce some materials for schools to use with or without outside assistance.






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 above. More details on junkbots can be found at http://junkbots.blogspot.co.uk/


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()



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


           

Excel to build and training a single artificial neurone

Two videos produced within the Department of Computing, University of Northampton, Uk on using Microsoft Excel to simulate a single artificial neurone, as a step towards building a neural network.

In the first video, Excel is used to build and show the principles of a single neurone.

 

In the second video the ideas from the video above are now extended to show, in a relatively simple way, how a single neurone can be trained.

 

The opinion bit - I think this is a relatively easy way to start playing with neuronal ideas. What would be interesting to find a way to build this idea into a simple neural network. Comments and ideas are very welcome.

Consumable Robotics UFO lands

CBiS Education generously sent me two of their new range of robotics development kits - Consumable Robotics (consumable-robotics.com), these are a range of cardboard based kits (so far a robot and a UFO) with electronic components for example LEDs; sensors and buzzers,  depending on the kits. What makes the kits interesting though is they are designed to be controlled by either by a BBC Micro:bit or a CodeBug.

This blog documents, briefly, an initial play with the UFO kit (see below) using a Micro:Bit for control. 

The UFO model came together readily, the instructions were fairly easy to follow. Personally, a feature I especially liked about the model was the LEDs being both on the top and bottom of it - increasing it usefulness. CBiS Education.

They have also provided a webpage / portal with some example projects and code. 



My first project I built, was to pulse the LEDs on and off (one set of LEDs on Pin 0, the other on Pin 1). Pin 2 was connected to the buzzer, so produce a low buzz every few seconds. The code below is written using the Block Editor (https://www.microbit.co.uk/create-code)

The video below shows the LEDs pulsing. I do need to decorate the UFO though!


 


Now I am going to play with it a bit more and add the light sensor, included in the kit, to it; so it can detect different light levels. Again it is controlled using the Micro:Bit.

Stage 1 - Decorating it
The kit comes with some stickers so I added a few.

Stage 2 Wiring
Pins 0 and 1 are outputs to the LEDs
Pin 2 is the input from the light sensor
The red lead from the light sensor connects to 3v and the grounds to the ground.


Stage 3 Code

The light sensor works more as a low light level detector, the darker the higher the value returned (in this case) on pin 2. So in low light level,  the LEDs flash relatively quickly, when the light level rises half of the LEDs start to pulse more slowly.




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.