Arduino and Traffic Lights

The internet is full of great project ideas for the Arduino, here is a tricky one that introduces you to an idea that actually occurs in real life.

Traffic lights



Hook up a circuit with a red, yellow and green LED and then hook it all up to the Arduino.

Program the lights so that the following cycle repeats continously:
-the red is lit up for 4 seconds
-the green is lit up for 4 seconds
-then the yellow is lit up for 2 seconds

When you get it working, try to add a photoresistor that when covered, forces the light to go straight to green, no matter what LED was lit up.
This simulates a pedestrian pressing the button in order to cross the road.

If you would like some help with the code, take a look at this document.