View on GitHub


The Pi Zero powered bot

Download this project as a .zip file Download this project as a tar.gz file


Welcome to the Henry github pages.

Henry is a Raspberry Pi Zero powered robot with a simple web interface for remote control. I was inspired by PiWars and the Zerobot feature in MagPi Magazine Issue 40 (Pi Zero launch edition) and wanted to get making. I have plans for a more complicated robot but this was a good starting point. This project is therefore just for fun.


Basic Robot Components

Henry uses most of the components featured in the zerobot article. Namely these are:

In addition to this Henry also uses:


The Zerobot tutorial was the starting point for me and this project. In addition to the Pi Zero it uses two stepper motors via driver boards and an HC-SR04 sensor to drive/walk around a set path unless it detects an obstacle. This is great but after attending PiWars in Cambridge I knew I wanted some form of manual control. My other plans for the more complicated robot will use a playstation controller but for Henry I wanted to keep it simple and so decided on a web interface. At some point in the future maybe i'll add some more automation too.

Flask Web Server

To allow for some basic controls I wanted to generate a web page in the easiest way possible. I came across Flask and decided to try it. I was running trial of PyCharm and it all just worked great together so stuck with it and implemented a basic template driven setup where the URL structure contained all the variables I needed (Direction, Gear, Speed).


The above sets direction of Forward, Low gear and Speed of 8. The flask template uses a number of HTML Canvas elements to draws all the arrows for movement with the correct link urls. This gave me complete flexibility on how it looks as well as being able to scale it based on the browser size / orientation being used. The page records these variables for the move() function to pickup later.

Updating ZeroBot Code

The ZeroBot code was a good start and gave me a basis for the motor control but I needed to make some changes to achieve what I wanted to. Firstly I wanted to extend the basic movement options from Forward, Back, Left and Right. While this seems to be enough(and is really) I wanted to investigate the options for turning. To spin Right there are now three options:

I also wanted to implement a 'Gear' option. The motor control boards support two sequences a 4 step and an 8 step sequence. The idea is that the 8 step is slower but has more torque (low gear) and the 4 step is faster but has less torque. The ZeroBot already had the sequence in place along with code to step through the 8 steps in high and low settings. All i had to do was add the button to the page and code it through to change the variable.

For speed control I decided to use a simple slider on the page ranging from 1 to 10. This is then mapped to a pre-defined 'waittimes' that affect the overall speed by slowing down the time between motor steps. A dictionary for high/low is used with tuples storing the actual speeds. Some wait time appears essential to allow the wheels to actually rotate between motor steps and so setting the wait time too low led to no movement at all. Finding the point at which movement was reliable and at it fastest dictated the wait time used for the max speed of 10. The slowest speed was set when the robot just moves and the numbers in between distributed. To my surprise the Low gear high speed appears higher in initial tests than the High gear option - If this is the case then the High gear is redundant.

Henry Lives


Henry Lives (Youtube)

Future development ideas

I'm already working on another robot but if/when I spend more time on Henry these are some areas I am currently thinking of: