My conferences on Lanyrd - Oli Allen's blog

Archive for the ‘Arduino’ Category


March 9, 2010

Controlling an Arduino with PHP

Since PHP is my language of choice, it wasn’t long before I wanted to use it to control my Arduino.

This turned out to be easier said than done – under Windows anyway, with a lot of vague (mis)information out there. Not to mention a lot of “RTFM” advice.

The way I ended up doing is still a little too hacky for me to be happy with – PHP is clearly the wrong tool for the job here.

The Problem

PHP has trouble communicating with serial ports – a class is available to handle serial communication for you, but under Windows is write only.

I installed RealTerm, which has a feature to echo a serial port to a TCP/IP port, which PHP has no problem dealing with. Essensially, RealTerm will relay things back and forth between my PHP script and the Arduino.

This worked great, but seems like an unnecessary layer, just for the sake of using PHP.

To test this, I made a simple circuit with two LEDs and a servo, and wrote a quick AJAXy page to control the script, which would send commands to the arduino.

s90 would turn the servo to 90 degrees

g15 would turn the green LED to 15

r0 would turn the red LED off

I made a quick video to show the result

And to show the data being relayed through RealTerm…

EDIT: Forgot to add, this also solves the problem of the Arduino resetting itself every time a serial connection is opened, because RealTerm opens one serial connection and keeps it open, regardless of the actual connections my PHP script makes.


March 3, 2010

My First Arduino

Tags: , , ,

A short year and three months after Nd suggested to me that I should acquire an arduino, mine arrived yesterday.

I went for the starter kit from Earthshine Design because, to be honest, I had no idea what kind of components I would be needing to get started – or even what to build!

The Earthshine kit comes with a nice PDF manual with step by step instructions to build a number of projects with the components supplied.

With that said – let’s get it out of the box 🙂

Earthshine Design Arduino Starter Set

The arduino itself. Oooh shiny.

Enough LEDs to light my entire house

And enough resistors for each of them 🙂

And… the rest of the components – many of which I don’t yet understand exactly what they do. Includes a motor, potentiometer, temperature sensor, switches, transistors and so on.

The kit also includes a USB cable to connect the arduino to your computer, a breadboard and jumper wires for easy prototyping (without going to the trouble of soldering etc) and a power adaptor to power the arduino when it’s not plugged in to a computer.

And that’s not to mention the cool case to store your components in!

The kit costs £49.99, which from the research I did, seems to be a good price for such a starter set. With so many components supplied and tutorials for projects to build with them, it’s going to keep me busy for a while.

Kit available from