IR Proximity changes LED’s

http://vimeo.com/moogaloop.swf?clip_id=2094937&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1
LED Switch with IR Sensor from Katrina Bekessy on Vimeo.

I tried Matt’s code and it worked well, but what you see in the video is my less sophisticated code at work which you can see here:

int irPin = 3; // IR sensor is read from pin 3
int irVal = 0; // hold the values read from the IR sensor

int orngPin = 9;   // Orange LED,   connected to digital pin 9
int bluPin = 10;  // Blue LED, connected to digital pin 10
int grnPin = 11;  // Green LED,  connected to digital pin 11

void setup()
{
  pinMode(orngPin, OUTPUT);   // sets the pins as output
  pinMode(bluPin, OUTPUT);   
  pinMode(grnPin, OUTPUT);
  Serial.begin(9600); //see what the heck my IR sensor is reading
}

// Main program
void loop()
{
  irVal = analogRead(irPin); 

  if (irVal>=200) //when you’re closest to the sensor
  {                  
    digitalWrite(grnPin, HIGH);
    digitalWrite(bluPin, LOW);
    digitalWrite(orngPin, LOW);
  }
  else if (irVal>= 75 && irVal<=200) //middle range of sensor
  {
    digitalWrite(grnPin, LOW);
    digitalWrite(bluPin, HIGH);
    digitalWrite(orngPin, LOW);
  }
  else if (irVal<75) //when you’re the furthest away
  {
    digitalWrite(grnPin, LOW);
    digitalWrite(bluPin, LOW);
    digitalWrite(orngPin, HIGH);
  }
  Serial.print(irVal);
  Serial.println();
}