Program.cs
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;

namespace Stop_Light___Simple
{
	public class Program
	{
		static OutputPort redLight;
		static OutputPort yellowLight;
		static OutputPort greenLight;

		public static void Main()
		{
			// setup the start button (interrupt port)
			InterruptPort startPort = new InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.Di2, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);

			// setup the light pins
			redLight = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di6, false); 
			yellowLight = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di7, false);
			greenLight = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di8, false);

			// reset the glitch filter
			TimeSpan ts = new TimeSpan(0, 0, 0, 0, 600); //600ms
			Microsoft.SPOT.Hardware.Cpu.GlitchFilterTime = ts;

			startPort.OnInterrupt += new NativeEventHandler(startPort_OnInterrupt);

			flashLights();

			// wait forever for input
			Thread.Sleep(Timeout.Infinite);
		}

		static void startPort_OnInterrupt(uint data1, uint data2, DateTime time)
		{
			Debug.Print("Starting the Seqence...");
			flashLights();

			redLight.Write(true); // start out with a red light
			Thread.Sleep(2000);
			redLight.Write(false);
			greenLight.Write(true);
			Thread.Sleep(4000);
			greenLight.Write(false);
			yellowLight.Write(true);
			Thread.Sleep(2000);
			yellowLight.Write(false);
			redLight.Write(true);
			Thread.Sleep(4000);
			redLight.Write(false);

			// clear the interrupt so we can start the process again
			//startPort.ClearInterrupt();

			Debug.Print("Seqence Complete.");
		}

		static void flashLights()
		{
			Debug.Print("Falshing the LEDs");

			bool r = redLight.Read();
			bool y = yellowLight.Read();
			bool g = greenLight.Read();

			//turn off all the lights
			if(r) redLight.Write(false);
			if(y) yellowLight.Write(false);
			if(g) greenLight.Write(false);

			for (int i = 0; i < 3; i++) {
				redLight.Write(true);
				yellowLight.Write(true);
				greenLight.Write(true);
				Thread.Sleep(350);

				redLight.Write(false);
				yellowLight.Write(false);
				greenLight.Write(false);
				Thread.Sleep(350);
			}

			redLight.Write(r);
			yellowLight.Write(y);
			greenLight.Write(g);
		}
	}
}