Raspberry Pi Endeavors 8 – Headlights and New Interface

Finally got the 20,000 mcd (micro candles?) super bright white LEDs from eBay, and attached them to the solder board in two sets of 3 LEDs. I have wired these up to seperate GPIO pins for now, in case I want to control the left / right headlights separately - but might change this as I’m rapidly running out of GPIO pins.

Headlights on Pi Car


I have also got round to redesigning the UI, which previously was all stock HTML buttons, stock jquery slider etc. Designed a few buttons on Fireworks, got some JavaScript to make the hazard warning lights button flash when they are on using setInterval and setTimeout (similar to sleep();).

Updated UI

Updated UI, with headlights on


Raspberry Pi Endeavors 7 – Hardware Parts List

I started off this project wanting to use the Mr.Basic 4wd microcontroller chassis, but after 2 bad experiences with them having so much resistance that they couldn’t turn their wheels, moved to a slightly beefier 4 motor chassis.  I got both a clear and black acrylic set of these from eBay (China), and have found them both to be of a much higher quality.

Parts list for my project:

Raspberry Pi

Funnily enough, you will need a Raspberry Pi for this. Get one from RS electronics / Amazon / eBay etc. About £25

Raspberry Pi

Raspberry Pi case

This “Environmentally Shell Kit Box For Raspberry Pi” case from oig.buy on ebay is the same style as the clear chassis I got, and provides very easy access to all parts of the Pi whilst protecting the top and bottom. Around £3

Pi Case

“Environmentally Shell Kit Box For Raspberry Pi” – eBay

1A micro USB charging cable

Good for powering the Pi or recharging the mobile phone battery pack that powers the Pi. I picked some up on eBay for £4.50.

Micro USB Charger



I picked up a couple of Logitech B910′s from Scan’s eBay store for £45 a pop, after using an old Microsoft lifecam, which worked fine, but the quality wasn’t so great, but you can pick them up for about £6.

Hello Kitty Webcam

The Hello Kitty webcam that Nick favoured


USB WiFi adapter

Eximax make great USB WiFi adapters that work natively on Mac and Linux (as well as Windows), and we found these to be awesome – as they just worked. It looks like Edimax recently just released a new black version, which I picked up for £15 on eBay. I also got a white, fairly new one that was a dongle plus antenna (all in one), and Nick used a white just antenna model, and all 3 models have been brilliant.

edimax USB wifi


12000 mAh mobile phone battery charger

I bought a couple of 12000 mAh mobile phone backup battery chargers to power my Pi when it goes mobile, and they last for somewhere near 8 hours. They are charged by a mini/micro USB cable, and output 1 and 2 amps over USB. Each cost around £17, and came with many little adapters to charge a variety of different phones, including micro USB for the Piberry Ras.

Mobile Charger



Electronic Components

4wd chassis

Around the £20 mark from China, I got 2 x 4WD, 4 motor chassis. [Clear one] [Black one]

Clear Chassis

Clear Chassis

Black Chassis

Black Chassis

Raspberry Pi Cobbler GPIO Super Start Kit from 4tronix_uk’s eBay store.

Including a huge breadboard, Adafruit cobbler cable and header, switches, resistors, LEDs and jumpers, the Cobbler Super Starter Kit was very useful starter kit full of essentials for messing around with the GPIO pins, and at £22, didn’t break the bank, and no soldering was required.

Cobbler starter kit

Raspberry Pi Cobbler

Including cable and header to extend the GPIO pins of the Pi to the breadboard, very good one made by Adafruit, although others are available such as this split one by Mallinson. I have one of each, but am yet to use the Mallinson one.

Mallinson connector

Mallinson GPIO Connector. Like Adafruit’s, but split at the end.


A 400 point breadboard is sufficient for the cobbler and motor chip.


Male to male jumper cables

I got a pack of 65 in my super starter kit, plus more from Maplin. Could make them yourself with bits of wire, but its handy to have the jumpers for quick prototyping.


LEDs and resistors

Handy for troubleshooting and emergency lights. I used some 20,000MCD super bright blue LEDs for my emergency lights, with 330 Ohm resistors, but they also seem fine without resistors, and a lot brighter. Waiting on some super bright whites for my headlights.



L293D motor control chip

I just put the motor chip straight onto the breadboard, straddling the central divide.  They cost about £3 a pop, and one chip can control two separate (sets of) motors, at different speeds, if you have two pulse width modulation outputs on the device (for the Pi, you would have to do one in software).

L239D Chip

Red and black wire

Wire is always helpful with electronics.

8 AA battery holder

To provide power for the motors

8 AA battery holder


8 x rechargeable AA batteries

I already had a set of 2600 mAh ‘hama’ AA batteries (cells) and a charger that I got from 7dayshop many moons ago. I managed to find another very similar set on eBay for £13. These high capacity AA cells have kept my Pi driving on and off for a week now, and kept my Xbox 360 controller going for months of light use. Heavily recommend getting rechargeables and a charger – saves the environment and you buying tons of batteries.

Hama battery charger

Other Tools

Pretty handy to have:

  • Wire cutters
  • Wire strippers
  • Pliers
  • Screwdrivers
  • Tape/sticky velcro
  • Multimeter
  • Soldering Iron, solder, safety glasses etc


Raspberry Pi Endeavors 6 – Power!

Having only 6 AA batteries for the 4 motors wasn’t enough, and even with my super friction-reducing sellotape, the car struggled to turn on the spot, with 1 or 2 engines  normally stalling. A maximum of 9v was being provided for the 4 6v motors (connected in parallel), resulting in around 2 volts per motor (max) at a quick guess. I grabbed an 8 battery holder from Maplin, hooked this up and the car is much happier now – can turn on the spot well, and goes a bit faster too.

Hazard Lights on

Pi Car 01 with hazard warning lights flashing

As well as my emergency lighting system (ELS), I made a tiny script to simulate hazard warning lights, for when the car is just pulled over at the side of a room. The interface to control the vehicle is very simple – yet functional! When time allows, I will break out the CSS and get it looking a bit fancier.

Pi Car 01 Interface

Pi Car 01 Interface including view from the onboard camera looking out of its garage at the parking marks (sellotape on the floor) and a captivated audience

The two fields at the bottom show the JavaScript and the driving shell script reporting the key down (e.g LEFT), and the key up (all off). This is helpful for diagnosing issues such as when the off instruction arrives before the on one, and so the car starts driving and doesn’t stop. This may be fixable by getting the page to constantly tell the Pi that ‘up’ is held down, and then if the Pi notices an absence of these instructions, it will know to stop.


Raspberry Pi Endeavors 5 – Building The Car

Unfortunately both Mr.Basic 4wd chassis’ that I got had such high resistance in them, they could barely spin their own wheels, let alone drive along the floor. I got these sent back and went for a larger vehicle made from 2 pieces of acrylic and 4 motors connected directly to 4 wheels, that I picked up from ebay for about £20 [from China].

clear chassis photo

I then followed Adafruit’s guide: Lesson 9. Controlling a DC Motor. This is a great guide to power one motor – to power another, just connect another 2 input wires symmetrically on the other side, same with the outputs to the motor. You also must connect the PWM pin 18 to the EN2 [right hand side PWM pin on the chip] to allow the Pi to control the speed of both motors. If you wanted them to go different speeds, you would have to use software to emulate a PWM pin, and then connect that to the chip – as the Pi only has one PWM pin.

L293D Chip

Picture: Adafruit Learning System (Lesson 9 DC Motor)

I then used a Raspberry Pi Cobbler from Adafruit to gain easy access to all of the Pi’s GPIO pins on a breadboard. On the breadboard, I placed the cobbler, L293D motor chip, and connected them both up with jumper wires, adding the batteries for the motors to the positive and negative rails. [Follow Adafruit’s guide!]

Wiring diagram

Picture: Adafruit Learning System (Lesson 9 DC Motor)

So now the Pi is connected to the breadboard, on which is a motor chip that controls the motors using inputs from the GPIO pins. If your batteries are charged [like mine weren't first time - diagnosed by putting an LED on the motor wires, and it glowing very dimly], you are ready to start asking the motor chip to power the motors. Again, follow the Adafruit instructions that get you putting e.g pin 4 high, which signals the chip to drive the left motor in one direction. You must also set the PWM (value of 0-1024 I believe) that controls the speed of the motor. I use at least 500, but normally closer to 1000 – as the if it is to low, the motors ‘stall’ and wont turn.

All you need now is some software to control it. Me and my housemate use an index.html file hosted on the Pi that calls a bash script whenever a directional key is pressed, then when it is let go, it runs an off script that turns all control pins back to 0. You can also use Python. I used Python to make the script to control the flashing emergency LEDs [superbright blue LEDs].

More soon!


Generate Many MAC Addresses – Keyboard and Mouse Recorder for Mac

I needed to generate a lot of unique MAC addresses for my virtual machines, and VMware has no function that I can find in vmrun to generate one. However, in the ‘Network Adapter’ settings of any VM, you can pummel ‘Generate MAC Address’ to create new, unique ones. One option was to generate that address, copy and paste it into a text file, and repeat – but I didn’t fancy doing this for however many I’d need (probably hundreds) – so I Googled for a ‘Ghost Mouse’ piece of software – and came across Keyboard and Mouse recorder for Mac by softonic.


Great. It recorded my mouse and keyboard inputs of generating, copying, alt-tabbing, pasting, hit enter for a new line. I could also loop this process – but only to a maximum of 10 times without registering. I didn’t fancy pressing the play button whenever it finished (about every minute) so after looking for a command line way to start it (thought I could use a minutely CRON job..) I found no man pages or anything. Therefore I just fired up a new instance of  the application, and got that to click the play button on the first one, and then stop recording after about a minute. Putting this on a 10x loop as well, it will press the play button on the 10x generate loop, 10 times – so generates them in batches of 100. Win.

“Wherever possible, cheat”