All posts by gbaman

Lego Pibot revision 0.2


I have been working away at my Lego Pibot recently and now have something to show for it.

I rebuilt the entire thing making it more efficient in turning, it uses a towering design and is more modular. It has 4 levels with batteries, pi, breadboard and camera.

It also has support for an additional attachment on the front, so far I have used that to attach a lift-able pen on the front to draw over paper (turtle style). Finally I have added space for a breadboard and also added the extra motor for rotating the webcam.

All the electronics are the same as the first Lego Pibot with the exception of the additional motor and the breadboard for prototyping. i have also added a cheap ultrasonic sensor off eBay to it but am having issues with it right now.

What isn’t shown in the video is the wiimote support I have added. I have written an additional script for controlling the robot with Bluetooth using a wiimote.

When it is finished I will post the source code, as normal, it is in python.

Also new is the addition of scratch controlling. The robot can be really easily controlled by scratch GPIO making it really simple to write control programs.


As normal, if you have any questions on this, post a comment below or on the video.



On Wednesday the 20th of April the Dalriada school robotics team traveled to Cambridge to compete in the PA Consulting Raspberry Pi competition. Our team brought with us a prototype of our revolutionary new product, the Raspberry Pi Powered Internet Connected Pill Dispenser. This device uses a raspberry pi, connected to the internet to dispense pills at predesignated times that have been defined on a custom made website of ours.

All this for under £50!

The prototype of the pill dispenser
The prototype of the pill dispenser

When we arrived we were met by some helpful PA Consulting staff that had been assigned as our representatives for the day. We went up through a maze of halls to the event room. A massive room with banners everywhere and a lot of raspberries. We went over to our area and set up

Our whole design is a bit of a mess but we left it out of its box so people could have a look and see how it worked

We have plenty of cables. Spot the raspberry pi in there.
We have plenty of cables. Spot the raspberry pi in there.

After setting up I was immediately thrown in the deep in with an interview as no one else in the team wanted to do it. You can see a shortened version in the video above.

We then got shown around PA Consulting’s building and got to see some cool 3d printers, a machine for making kitchen roll (Way more exciting that it sounds) and a number of other activities planned for us. We then had to demo our design to a number of judges, this went ok but could have gone a lot better after a jammed the machine up by pulling out the wrong bit ūüôā

After this the judges continued round the rest of the teams and members of the press and PA Consulting clients came and we presented our product to them, these seemed to go a lot better and we ended up with a number of impressed people including a lot of “My mother/father would greatly appreciate one of these”.

After a tantalizing wait, the judges announced the winners including us and we each walked away with a raspberry pi (My 4th raspberry pi) and a PIbow. The school got a golden envelope with £1000 in it (which we plan to spend on a classroom of raspberry pis) and an custom engraved Pibow case.


We had a stunning day and would especially like to thank PA Consulting for putting on this event

Check out what other bloggers have said

Lego Pill Dispenser

Our summary documentation can be found below


A big feature of our pill dispenser is the price, we have designed it to be as cheap as possible and a one off payment, no subscription required!
What you will need

  • A Raspberry Pi = see below
  • A motor controller = ¬£4.75
  • Some jumper cables = 10p
  • A breadboard = ¬£1
  • A wifi network
  • Some lego
  • 2 Lego motors = ¬£15
  • Power cable = ¬£2
  • Motor batteries = ¬£3
  • Some other cables = 10p

We offer 2 versions to keep the price down. Wifi only or Ethernet only.
This is all to do with the raspberry pi.
If the user needs wifi we use a model A raspberry pi with an added £10 wifi adapter = £28
If the user only needs Ethernet we use a model B raspberry pi only. = £27

Total price = £53 including Raspberry Pi one off payment (no profit) and £26 excluding Raspberry Pi

Next grab a copy of the PHP site behind it all from

It will need to be running off an apache webserver with PHP currently (recommend XAMPP which can be found here

Onto the raspberry pi

sudo apt-get git

git git clone git://

Back to the webserver

Now we have the web server and the pi set up it is time to configure them.

They are already configured out of the box with everything except the dispenser IP address.

To get this, type ifconfig on the raspberry pi and find the series of 4 numbers with a . in betweeen each number. E.g.

Next, open up the website (using a browser go to localhost) and log in with



Now select a patient with the dropdown menu at the top and double click the dispenser IP address. This will let you change the IP address of the dispenser to your dispenser’s IP address.

The uploaded software is in demo mode so it works in minutes and does not show the normal time selector for selecting different times of day to be dispensed.

A useful diagram from explaining connections for our motor controller used

Now hook up all the wiring using the above diagram and you are ready to go.

Raspberry UART – No screen or network needed! WOOT!

My USB to UART bridge adapter arrived today all the way from China. I have been wanting one of these ever since turning up to a raspberry jam to discover they didnt have any more screens left and their network was overloaded meaning i had no way to control my Pi.


So after some research I disovered the raspberry pi supported a serial connection (UART) to control the console. I ordered this device which took 1-2 weeks to arrive (¬£1.65 so can’t complain…)

I wired it up with

  • +5v to pin 2 (optional see below)
  • GND to pin 6
  • RXD to pin 8
  • TXD to pin 10

I then grabbed the driver for it (windows does not auto find a driver) from Silicon Labs

After installing the driver, I opened up device manager, drilled down to Ports (COM & LPT) and found the COM port it was on (COM4 for me).

Now we have all the info we needed, I opened putty up, clicked serial circle tickbox and entered my COM port. Finally I entered the correct speed for the Pi (115200), clicked open and hit enter and I had a login prompt!

Much cheaper than a screen or a router and perfect for Raspberry Jams!

As normal, any questions? Leave them below

Lego PiBot

 Outdated. Check out updated version revision 0.2!

Lego Pibot

I would like to start off by saying, I didn’t come up with all this myself, I have followed a few guides over the internet to make this and added a bit of my own stuff to it. The guide I used the most was

You will need

  • A Raspberry Pi + SD card
  • A Motor controller

Motor controller

  • A Wifi dongle

USB wifi reciever

  • A battery for the Pi

Old Iphone battery

  • A 9v battery
  • 2 motors
  • Female to female jumper cables
  • Male to male jumper cables
  • Android phone – rooted


  • Webcam
  • Mobile tablet/Laptop for viewing video feed
  • Mifi portable wifi transmitter

First you will need some sort of base robot to be building this all on, I will only cover the electronics and the software, not how to build your robot.

So here’s my base robot

Lego PiBot Lid

Lego PiBot no lid

It looks a little ugly, but was built to a deadline so I don’t really mind, it works.

So after you have got everything on shopping list, its time to start building!

My lego robot base is built from an old lego RCX box set so I decided to try and use some of the old 9v lego motors.

Lego 9v motor

These motors required gearing to provide enough torque to move the robot forward so if using these motors, keep that in mind. I did come across another problem with these motors, they don’t easily connect to normal wires…

So I cut one of their cables and soldered it to 2 jumper cables and bam!

My custom lego cable

So now we have our motors, we need to hook our motor controller up to the raspberry pi. For this, I recommend you check out the diagram from Paul Geek Dads blog as it is the one I used.

This is Paul Geek Dads blog’s work, all rights to it belong to him

For my setup I found that a 9v battery would run out very quickly so I got x2 triple AA battery holders to produce that required 9v


So now we have our Raspberry Pi hooked up to our motor controller and our motor controller powered by a 9v battery or some AAs.

Check out the below pictures for pictures on where everything goes

Electronics Electronics Electronics

Note the Pi ground and the black end of the batteries cable both go into GND
Note the Pi ground and the black end of the batteries cable both go into GND

Now time for the software behind it all. I am using Rasbian. At the time of writing, 2012-12-16-wheezy-raspbian. Rasbian comes with WiringPi which is needed for our scripts, if you don’t have it, try sudo apt-get wiringpi

For this section, that is all you need (for attaching a webcam, you will need a little more software but we will get onto that later)

Hook your pi up to a screen and with your wifi dongle plugged in, type startx and open the wifi config on the desktop. Connect to your home wifi. Now that this is done, it should automatically connect to the wifi even without a screen plugged in (seeing as the PiBot does not have a screen….Yet).

The Raspberry Pi

Next, on a windows computer, grab putty

Or if on Mac OS or Linux, open terminal and type

ssh pi@IP address

E.g.        ssh pi@

Now we are connected, you will need to grab this python script and upload it onto the pi

Use sudo apt-get git

and git clone git://

To grab the script for the pi. Now you have the scripts, it’s time to move on to the phone.

The Phone

You will need a rooted android phone which can run sl4a

To grab it just scan the qr codes on the pages below.

SL4A –

Python interpreter  Р

This great piece of software allows you to install interpreters on your android rooted device (e.g. python interpreter).

Next find a way to get the script onto your phone (different for all phones).

Now you need to set the IP address of your Pi in the scripts. In the android script it is on line 12, UDP_IP =

And on the Pi script it is on line 25, UDP_IP =

Now all you have to do is tap the script and click the command-line button and run the Pi script (sudo python to run it and move your phone around and your robot should move!


Live video! (Optional)

Wouldn’t it be even cooler if you could see what your robot sees as you drive it around? We you can!

I recommend following this guide below, it is very good and explains exactly how to do it.

After following the guide, open up the web page on a smartphone, maybe a tablet or a laptop etc and you can now watch your robot take over the world!


If it does not work there is a few things that could have gone wrong.

First test if your Pi is able to turn control the motors. Inside the Pi folder that you grabbed off github, there is a and Try running these and see if the motors come on. If not, check the light is on on the motor controller, if not, check back to the pictures for wiring or maybe your board is broken?

If those scripts work then your phone isn’t able to talk to the Pi… Make sure the IP address is right (use ifconfig on the pi) and maybe try rebooting your Pi and phone just in case.

If it still isn’t working, leave a comment below and I may be able to help out.


Any question? Leave them below and I will try to answer them the best I can.