Archive

Projects

My long-awaited Arduino Duemilanove board arrived today. Great! Now I have a use for all the miscellaneous electronic kit I have been randomly purchasing over the past week-and-a-half.

After 10 minutes, it was connected, and the obligatory “Hello World” flashing-LED had been created. Woo! Sure it’s simple, but my entry into the world of physical computing. Just a few minutes later, I’d expanded that solitary LED into a chain of 5 blinking LEDs (I know what you’re thinking: “that’s awesome, Rich”).

My first project: timer-based traffic lights

Given that I don’t have any force-sensors or other sensing gadgetry laying around just yet, I decided to model a simple, timer-based traffic light model comprising of three LEDs, and four combinations of light:

  • Red
  • Red + Amber
  • Green
  • Amber

(In the UK, that’s the sequence of traffic lights we use to dictate: “Stop”, “Proceed if it’s OK”, “Go”, “Get ready to stop”.)

I decided that, for the purposes of my first adventure, I would run the lights on a simple 2.5 second timer (long enough to figure out if the sequence is right, quick enough to prevent instantaneous brain boredom, waiting for them to change).

So, without further ado, the grand unveiling, here is my first Arduino circuit:

Arduino Traffic Lights (Timer version)

Given that’s so messy, here’s a circuit diagram, created using Fritzing (which is awesome, by the way – go get it, it’s free):

Ignore the fact it says “Arduino Diecimila”, I’m actually using the Arduino Duemilanove which I’m told is the newest one. I don’t think Fritzing has been updated with the new part just yet, but of course the bits you’re interested in are the pin connections…

Here’s a video of the traffic light sketch in action:

For posterity, I’ve also shown the sketch used to create this marvellous display of light:

/* Richard's Traffic Light Program */

int pinRedLed = 2;
int pinYelLed = 3;
int pinGrnLed = 4;
int lightState = 0;

void setup() {
    pinMode(pinRedLed, OUTPUT);    /* Set the LED pins to output */
    pinMode(pinYelLed, OUTPUT);
    pinMode(pinGrnLed, OUTPUT);
    digitalWrite(pinRedLed, HIGH);  /* Turn the RED light on, so we don't cause any traffic accidents while we initialise :) */
}

void loop() {

    lightState++;
    if (lightState > 3) {            // If the light state > 3, reset it to 0 (red).
      lightState = 0;
    }       

  delay(2500);

  /* Display correct light sequence */
  if (lightState == 0) { // Red
    digitalWrite(pinRedLed, HIGH);
    lightOff(pinYelLed);
    lightOff(pinGrnLed);
  }
  if (lightState == 1) { // Red and Amber
    digitalWrite(pinRedLed, HIGH);
    digitalWrite(pinYelLed, HIGH);
    lightOff(pinGrnLed);
  }
  if (lightState == 2) { // Green
    digitalWrite(pinGrnLed, HIGH);
    lightOff(pinYelLed);
    lightOff(pinRedLed);
  }
  if (lightState == 3) { // Amber-only
    digitalWrite(pinYelLed, HIGH);
    lightOff(pinRedLed);
    lightOff(pinGrnLed);
  }

}

void lightOff(int pin) {
  digitalWrite(pin, LOW);
}

So what’s next?
Tomorrow, or as soon as I get some more spare time, I’m going to modify this sketch to wait for a button press before changing the light sequence (instead of working on a timer). Actually, thinking about it, it would be good to have the lights operating autonomously on a timer, but as soon as a button is pushed, stop the traffic (go to Amber, then Red), wait for 10 seconds to let our pedestrians cross the road safely, then let the traffic pass again (go to Red + Amber, then Green) and then resume timer functionality. Ooo! That sounds exciting! :)

/Rich

Ok, so I couldn’t wait for Tinker.it’s Arduino Starter Kits to come back into stock – I’m so impatient. I also didn’t want to pay $40 for US shipping (after having to admit I overspend on ‘gadgetry’), so I sourced an Arduino board from coolcomponents.co.uk, and hit Maplin for just about everything else. As this is my first ever foray into ‘physical computing’, I decided that I needed, well, everything. So I went and bought a Jump Wire Kit, a breadboard kit with banana sockets for power, a regulated switchable DC power supply, about a trillion LEDs, resistors, capacitors and anything else that looked ‘electronicy’.

I also bought Physical Computing and Making Things Work – two excellent books.

So all this stuff has arrived, but my Arduino, ordered on the same day, hasn’t. So right now I’m like most kids who are stuck indoors looking out at the snow: I really, really just wanna play! :)

I recently purchased an Acer Aspire A150 from Amazon.co.uk. At just under 200 pounds, it is probably one of the best buy netbooks on the market right now.

It comes in several varieties, but I opted for the 160gb / 1GB RAM version with Linpus Linux installed, knowing that I would install Vista or XP on it soon.

Having lived with the netbook for a week running Vista Business, it was just too slow (remember, I have the 1GB RAM version – Vista really needs a minimum of about 2GB to be ‘bearable’). So the obvious answer then, not particularly wanting to use a Linux distro, was to install Windows XP.

That wasn’t as easy as it perhaps could have been, I think it is fair to say; taking up most of the day researching yesterday. There are several versions of tutorials on the web, it’s fair to say not all of them are written perhaps as well as they could have been. The best one, by far, in my humble opinion, was the one on the Acer Aspire One User Forums. This is an ‘unoffical’ community for Aspire One users, and the overall site is brilliant.

Before you trundle over to the user forum, have a look at the list of software I recommend you download before you begin. This is in addition to the list provided in the Aspire User forum article, above:

Virtual CloneDrive is basically a utility that let’s you ‘mount’ an ISO file into a virtual CDROM drive. ISO Recorder lets you create the ISOs that you can load into Virtual CloneDrive. nLite is a very smart program that lets you customise your Windows XP installation media before you install it.

Important note: In order to put Windows XP on your Aspire One, you will need to customise the installation media using nLite and apply Service Pack 1. If you do not do this, you will not be able to even run the installer on your Aspire.

Follow the instructions contained in the article above, and remember to do things in this order:

  • Make an ISO of your Windows XP CD
  • Mount your Windows XP ISO using CloneDrive
  • Run nLite – and make sure you add “Service Pack 1″ (VITAL)
  • Save your ‘nLited’ version of Windows XP somewhere on your hard drive
  • Follow the instructions in the article to create your bootable USB memory stick
  • Copy the nLited version of Windows XP onto your USB key
  • Insert the USB key into your Acer Aspire One
  • Boot up your Aspire One, and press F12 to enter the boot menu.
  • Choose “USB Key” from the boot options.

Voila!

Follow

Get every new post delivered to your Inbox.

Join 262 other followers