Project Status: Abandoned

Robots > PiBot

Click on the links below to jump to the various sections of this design….

  1. Brief & Inspiration
  2. Time & Money
  3. Set up the Pi
  4. Webserver
  5. Flashing LEDs
  6. Flashing LEDs from a web page
  7. It Speaks!
  8. Servos
  9. LCD Screen and Buttons
  10. Motors
  11. Tracks
  12. Further Reading



Robots… I love Robots!
I’ve been looking at various robots for years and now happen to have a spare Pi lying around. I want to spend as little as possible which is handy as I already have a Pi and a wireless dongle. This should cover me for the brain of the robot and I can publish a webpage to a webserver running on the Pi which allows me control over the GPIO pins (General Purpose Input Output).

Raspberry Pi Logo


Code Examples
I am going to document the working code as and when I get some! If you see a “Code So Far…” link then click to expand this and see working version of the code so far, you may want to ignore this and figure it out for yourself! If you do use my code please check it first, I do not guarantee that it will not break your Pi, sleep with your wife, burn your house down or anything else!


Brief & Inspiration

After doing some research I’ve found a pile of useful websites… I’ll try and link to each tutorial as I go so you can see my research!

Return to the top of page.

Money is going to be out on this project as I already had a Raspberry Pi B and power supply (~£35) and a WiFi adaptor (~£8) left over from a previous project.So if you are staarting from scratch, research prices for those on top!


Time & Money

  Estimated So Far…
Time to Design 100 hrs 5 hrs
Time to Build
(Including sourcing/scrounging materials!)
100 hrs 4 hrs
Cost to Build £100 £0

Return to the top of page.


Pi Setup

I’ve been following various tutorials and installing various things! So far I have Raspian on an SD card, I’ve enabled and tested VNC and SSH and installed a wireless card.

Installing Raspbian…

First Time Config…

Configuring SSH…

Configuring VNC…

Setting up WiFi

Next steps will be to install Apache and confirm I have a webpage being served up from the Pi, then check I can use in the GPIO for input output.

Return to the top of page.



Install Apache / PHP

At this point you should now have only one cable connected to your Pi (5v Power) and you should be able to browse to your Pi’s IP address and see the default Apache webpage.

Default Apache webpage
Default Apache webpage

Return to the top of page.


Flashing LEDs

Get an LED to blink… now there are lots of tutorials on this but the following ones I found well done and without someone insanely annoying doing the video!
[Edit: for future reference I linked the GPIOs out through the various LEDs and then back to Ground…. I’ve taken it apart once and had to look it up again.]

e.g. GPIO27 = Pin 13!

The ModMyPi series of videos: https://www.youtube.com/watch?v=OR5h0UnMcUE
The AdaFruit tutorials, although I couldn’t find a basic ‘Flash an LED’ tutorial they are worth going through: https://learn.adafruit.com/category/learn-raspberry-pi
This is a nice one as well: http://roverpi.blogspot.co.uk/2013/06/getting-leds-to-light-up-with-raspberry.html

Here’s my three LED code I ended up creating and how to run it…

3 LED Code
3 LED Code
Running a python script
Running a python script

You should now be able to connect wirelessly to your Pi by VNC and/or SSH and run your LED script to flash some LEDs. The next challenge is to get a button on a webpage to run that script!


Return to the top of page.


Flashing LEDs from a webpage

[Edit: for future reference its on port 8000!!]


This is my first attempt for the web page… but I’ve done websites for a while so this was fairly straight forward for me. I’ll get some downloads sorted so you can download my version of the code…

Pibot Webpage v1
Pibot Webpage v1

As an aside this is fairly helpful…

Make a shortcut to my windows share from my pi

Code So Far... (Click for disclaimer and link!)
Click the link below for a zipped version of my project files. Please note that I do not guarantee that the code will not break you Pi, sleep with your wife, burn down your house or do anything else! This is a work in progress. Save the files to your working directory defined in the WebIOPI config. Project5-3LED

Return to the top of page.


It speaks!

The next plan is to make it speak, as this is free pretty much! At this point the robot isn’t moving so I could just plug the 3.5mm jack output of the pi into a spare input on the stereo.

I followed the steps in this tutorial…


…and basically didn’t bother with a button! First thing is to check you can play an MP3 by running a python script and then run the same code from a button press on the WebIOPI page we created earlier. I’ll post code examples later 🙂

Audio Samples!
Yes! My Robot is going to have the voice of Ash from Army of Darkness!

  • http://www.freesound.org/search/?q=droid&f=&s=score+desc&advanced=0&g=1
  • http://movie-sounds.org/horror-movie-samples/army-of-darkness-1992/

Some of the audio samples are a bit raw but you can clean them up and sort out the levels using Audacity – http://web.audacityteam.org/

Code So Far... (Click for disclaimer and link!)
Click the link below for a zipped version of my project files. Please note that I do not guarantee that the code will not break you Pi, sleep with your wife, burn down your house or do anything else! This is a work in progress. Save the files to your working directory defined in the WebIOPI config. Project6-3LED_Audio

Return to the top of page.


A note on terminal controls

I realised that I write a lot of code by through an SSH putty Connection and that I have been teaching myself terminal commands but not shared them or written them down… so here are the basics. I’m used to a Windows environment and there is a fair amount of crossover…

CD – change directory!
To change the current working directory from ~/pi/ to ~/pi/pythoncode would be “CD pythoncode
To change the current working directory from ~/pi/pythoncode to ~/pi/ would be “CD ..“, two dots is essentially “up one level”

MKDIR – Make Directory
To make a directory called “bingo” in the current working directory you would type “mkdir bingo

CP – Copy
To copy a folder contents to another folder, ~/pi/script-live to ~/pi/script6-audio, I would type “CP ~/pi/script-live ~/pi/script6-audio -r“, you need the -r to make it recursive copy otherwise it would only copy files that you specify and not folders!

The reason that I work like this is that I can type and view code on my laptop rather than through a VNC connection to my Pi and I can still copy and paste into Putty. Prior to each major code change I take a copy of the working directory and save it a level higher with an appropriate name!

Basically my folder stucture is like this

Folder Structure

Any files in the Project-Live folder are the ones referenced by WebIOPI and are the “live” scripts.
This way if I make a major stuff up I can just copy the contents of the highest numbered project folder over the contents of the Project-Live folder and I am working again (basic versioning)!

Return to the top of page.


Backing up the scripts

Browse to the folder containing all of the project folders, right-click on the folders and select Open in Terminal.


Then type…
sudo cp * /mnt/PiData -r
…PiData is the name of my SMB share from my Windows server (it could be a desktop or laptop though) that I have mapped following one of the links earlier. Be careful this will copy the contents of your current working folder to a mounted folder called PiData! The “-r” switch makes it including sub-folders and contents.

Return to the top of page.



I need to reread all of my motors links!
…but the first step is using the servos that I have!


Hmmm struggling to get that working so I’m going to follow a tutorial first to check everything works.


OK, so also struggling to install WiringPi! This is what I get:

$ sudo apt-get install wiringpi
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package wiringpi is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'wiringpi' has no installation candidate


OK… so update things first!

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

That kind-of worked and I now have a servo motor that randomly twitches!

Return to the top of page.


LCD Screen

I wanted to add an LCD screen so I can get some feedback from the robot without having to add a screen, keyboard and mouse.


I actually got a knock-off one from AliExpress but this is basically it. My plan is to have the screen display the IP address in case I can’t get to it! This actually comes with a lot more than I though so maybe I can change the background colour to indicate a status (Green = good, red = fubar…).

Mine came ready assembled which is good as I suck at soldering…. so straight onto the coding:


Return to the top of page.



Trying to stick true to my doing it on the cheap idea I have ripped apart a CD drive and a couple of printers to scavenge a variety of Motors, Switches, Cogs, Springs, Belts and Cables!

So far I’ve connected everything up, now for the code and batteries.



The idea is to eventually have it tracked! I could custom make a chassis and tracks but they’ve dropped in price and it looks like I can get a cheap one about the right size for ~£15.

Return to the top of page.