IR sensor + Winbond

Sweet, I still need to mess with the code a bit. Got me thinking about integrating it into a chair that will say things like ‘DON’T SIT ON ME’ or ‘WHY AREN’T YOU SITTING’ or ‘TAKE A SEAT.’ Making inanimate objects communicate. Maybe an egg slicer that says ‘NOOOO DON’T KILL ME!’ when the slicer gets through the egg.

http://vimeo.com/moogaloop.swf?clip_id=2148514&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1
IR sensor + Winbond from Jessica Floeh on Vimeo.

See following link for code (slightly altered from Katrina’s 3-leds code):

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

int orngPin = 6;   // WHITE LED,   connected to digital pin 9
int bluPin = 10;  // GREEN LED, connected to digital pin 10
int grnPin = 12;  // BLUE LED,  connected to digital pin 11
int playPin = 3; //attached to play switch on winbond chip
int fwdPin = 4; //attached to fwd switch on winbond chip

void setup()
{
  pinMode(orngPin, OUTPUT);   // sets the pins as output
  pinMode(bluPin, OUTPUT);   
  pinMode(grnPin, OUTPUT);
  pinMode(playPin, OUTPUT);
  pinMode(fwdPin, 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(playPin, HIGH);
    digitalWrite(fwdPin, LOW);   
    digitalWrite(grnPin, HIGH);
    digitalWrite(bluPin, LOW);
    digitalWrite(orngPin, LOW);
  }
  else if (irVal>= 75 && irVal<=200) //middle range of sensor
  {
    digitalWrite(playPin, LOW);
    digitalWrite(fwdPin, HIGH);
    digitalWrite(grnPin, LOW);
    digitalWrite(bluPin, HIGH);
    digitalWrite(orngPin, LOW);
  }
  else if (irVal<75) //when you’re the furthest away
  {
    digitalWrite(playPin, LOW);
    digitalWrite(fwdPin, LOW);
    digitalWrite(grnPin, LOW);
    digitalWrite(bluPin, LOW);
    digitalWrite(orngPin, HIGH);
  }
  Serial.print(irVal);
  Serial.println();
}