Friday, 22 January 2016

mini-projects: Raspberry Pi , Python, Pimoroni ExplorerHat Pro to build a Junkbot (revised)



Junkbots (http://junkbots.blogspot.co.uk/) are based around using  materials such as drink's cans, broken propellors and motors to produce something that moves by vibration. Previous designs can be found at:



The latest tweak to the Raspberry Pi based Junkbot design is to use the combination of Python and Pimoroni's Explorer HAT PRO 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()

spin1(1)
spin2(1)

Essentially the code spins the junkbot one way and then the other.

One extension thought understand consideration, is to use a Raspberry Pi Zero and Pimoroni Explorer pHat (https://shop.pimoroni.com/products/explorer-phat) and carry it on the junkbot.

If you do use or modify please leave a comment, I would love to see what others do with it.


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