A couple of years ago, I wrote about the “traffic lights” I’d created for my home office (and subsequent “upgrade”). Shortly after that, I updated the solution to use three LEDs (as shown below) but it still wasn’t quite what I needed. Walking to the door to push a button and change the light defeated the object somewhat. I needed to enable this device with a “web service”!

The solution comes in the form of an Arduino Ethernet Shield, allowing pin control over a standard Ethernet connection. I didn’t use the official shield though – cheap imports can be found on eBay for around £7. Following that, I amended my code using the Instructables Arduino Ethernet Shield Tutorial and another Instructables post on controlling an LED over the Internet using an Arduino.
The end result is below (or on Github) – and the Arduino uses DHCP to obtain an IP address (reservations can be used to control which one – or DHCP logs can be analysed) and a simple query string is read to set the light using:
- http://xxx.xxx.xxx.xxx/?r for red.
- http://xxx.xxx.xxx.xxx/?a for amber.
- http://xxx.xxx.xxx.xxx/?g for green.
Anything else fails back to red.
Red/green LED indicator with pushbutton control
Based on http://www.makeuseof.com/tag/arduino-traffic-light-controller/
USE_GITHUB_USERNAME=mark-wilson
*/
// Setup Ethernet Shield
#include <SPI.h>
#include <Ethernet.h>
boolean reading = false;
// Enter a MAC address and IP address for your controller below.
// The IP details will be dependent on your local network (commented out if DHCP in use):
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// byte ip[] = { 192, 168, 0, 112 }; //Manual setup only
// byte gateway[] = { 192, 168, 0, 1 }; //Manual setup only
// byte subnet[] = { 255, 255, 255, 0 }; //Manual setup only
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
// Pins for coloured LEDs
int red = 3;
int amber = 4;
int green = 5;
int light = 0;
int button = 2; // Pushbutton on pin 2
int buttonValue = 0; // Button defaults to 0 (LOW)
void setup(){
Serial.begin(9600);
// Set up pins with LEDs as output devices and switch for input
// Pins 10,11,12 & 13 are used by the Ethernet Shield
pinMode(red,OUTPUT);
pinMode(amber,OUTPUT);
pinMode(green,OUTPUT);
pinMode(button,INPUT);
// start the Ethernet connection and the server:
Ethernet.begin(mac);
//Ethernet.begin(mac, ip, gateway, subnet); //for manual setup
server.begin();
Serial.println(Ethernet.localIP());
}
void loop(){
// listen for incoming clients, and process qequest.
checkForClient();
// Read the value of the pushbutton switch
buttonValue = digitalRead(button);
if (buttonValue == HIGH){
changeLights();
delay(1000); // Wait 1 second before reading again
}
}
void changeLights(){
// Change the lights based on current value: 0 is not set; 1 is red; 2 is amber; 3 is green
switch (light) {
case 1:
turnLightAmber();
break;
case 2:
turnLightGreen();
break;
case 3:
turnLightRed();
default:
turnLightRed();
}
}
void turnLightGreen(){
// Turn off the red/amber and turn on the green
digitalWrite(red,LOW);
digitalWrite(amber,LOW);
digitalWrite(green,HIGH);
light = 3;
}
void turnLightAmber(){
// Turn off the green/amber and turn on the red
digitalWrite(green,LOW);
digitalWrite(amber,HIGH);
digitalWrite(red,LOW);
light = 2;
}
void turnLightRed(){
// Turn off the green/amber and turn on the red
digitalWrite(green,LOW);
digitalWrite(amber,LOW);
digitalWrite(red,HIGH);
light = 1;
}
void checkForClient(){
EthernetClient client = server.available();
if (client) {
// An http request ends with a blank line
boolean currentLineIsBlank = true;
boolean sentHeader = false;
while (client.connected()) {
if (client.available()) {
if(!sentHeader){
// Send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
sentHeader = true;
}
char c = client.read();
if(reading && c == ' ') reading = false;
if(c == '?') reading = true; //found the ?, begin reading the info
if(reading){
Serial.print(c);
switch (c) {
case 'a':
turnLightAmber();
break;
case 'g':
turnLightGreen();
break;
case 'r':
turnLightRed();
break;
}
}
if (c == '\n' && currentLineIsBlank) break;
if (c == '\n') {
currentLineIsBlank = true;
}else if (c != '\r') {
currentLineIsBlank = false;
}
}
}
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection:
}
}
All it needs now is another service to read my Lync status and call the Arduino accordingly, although, having got this far, I have to admit the form factor is not exactly brilliant and I probably should spend the money on a Busylight or a Blynclight instead so that my Arduino can be repurposed for a new project!
Or, of course, there’s Garry Martin (@GarryMartin)’s beautifully simple approach:
@markwilsonit Ultra low-cost; connect 240V bulbs to light circuit and use three gang light switch… pic.twitter.com/Q6twiDDIOM
— Garry Martin (@GarryMartin) October 17, 2014
I’m still enjoying 
Windows Phone 7.8 was a disappointment and the lack of apps for the Windows Phone platform means I’ve gone back to iOS for my personal phone (
My iPad never replaced a laptop as a primary computer but it’s still great as a Kindle, for catching up on social media content, and for casual gaming (read, occasional babysitter and childrens’ amusement on long car journeys).
This PC is my main computing device and is a small form-factor replacement for the previous Lifebook I used. I like it, but a BYOC scheme would be more likely to leave me buying a competitor’s PC. Just as well we only have CYOD! Verdict 7/10. Still hoping for a BYOC scheme at work but not holding my breath.
Rarely taken out of the drawer – only used when I want to play with Linux (Ubuntu) or upload some new code to the Arduino. Verdict 2/10. Not worth selling, so keep for tech projects.
Although I’ve fallen out of love with photography, I’m sure I’ll get back on the wagon some time. A full-frame DSLR is still my favourite format and the D700 will be with me for a while yet. Indeed, it’s more likely that I would buy some new lenses and a flashgun before I replace my camera body. Newer bodies offer video but I don’t miss that, and the low light performance on the D700 is pretty good. The P7100 continues to function as my carry-everywhere camera (it lives in the car), offering entry-level DSLR levels of control in a small package, although it’s not as responsive as I’d like and I increasingly tolerate using the iPhone instead (poor camera, but always with me). (D700) Verdict 9/10. Hold. (P7100) Verdict 6/10. Hold.
My MacBook is getting old and, although I upgraded to a 750GB disk, I’m struggling with disk space whilst 4GB of RAM is starting to feel a bit light for big Photoshop jobs but new Macs are expensive. Still too expensive to replace, but as long as I’m not doing much photography, this will last a while longer… Verdict 4/10. Hold.
No change here since last year and I still haven’t re-ripped my CDs after the NAS failure a couple of years ago (although the Dell server I bought a few years ago has come out of retirement in preparation for that task). We bought a Yamaha PSR E-343 music keyboard for my son this Christmas so this PC may be brought back to life with Garage Band or as a media server as it takes up almost no space at all. Verdict 6/10. Hold.
I don’t play this as much as I should but my sons make more and more use of it, and bought me a copy of FIFA 2014 for Christmas, so the Xbox is starting to get a lot more use. No plans to replace it with a newer model though. Verdict 7/10. Hold.

This PC is my main computing device. I’d love a ThinkPad, but the Lifebook is a perfectly capable, solid, well-built notebook PC, although I frequently find myself running out of memory with the number of tabs I have open in a typical browsing session! A recent hard disk failure meant my free space dropped (my 250GB drive was replaced with a 160GB one) but it’s due for replacement soon.
I decided that I should use 

Install the USB-serial drivers.