IR detector transistor?

Hey!

I'm trying to built IR object detector. Need help to connect that 3 wire IR transistor? I have made some circuits, is these ok?

Got that IR led and IR detector transistor from an old ball mouse.

Got that IR led and IR detector transistor from an old ball mouse.

The last IR detector I got from a mouse wasn't so straight forward. You only got pulses out of it when there was the twin signals of an encoding wheel blocking out the light. You might have to buy an IR detector. The IR emitter should be OK though.

Ok, got something now.

I used this detector transistor, got it from some old dvd player i think.

IR transisitor pins:


l IR l
l l

I I I
SIGNAL---I I I---5v
l
GND

Wired all up like this:

l IR l
l l

I I I
Pin_2---R1(1kohm)---I I I---5v
l
GND

int IRdetector = 2;       // ir detector pin
int ledPin = 13;  //led pin
int val = 0; 
int value = LOW;  

void setup() {
  pinMode(IRdetector, INPUT);      
  pinMode(ledPin, OUTPUT);
 Serial.begin(9600);  
}

void loop() {
  val = analogRead(IRdetector);  // read the value from the sensor
Serial.println(val);  
if (val <= 500) {
   if (value == LOW)
            value = HIGH;
         else
            value = LOW;
         digitalWrite(ledPin, value);
         delay(200);
      }
  delay(5);                        
}

When i run it and look serial monitor it gives me always value 1023
When i press my TV remote control(any button) it goes to 1(sometimes 2) and the led turns on/off.

Thats cool but actually i need something like this:
when i slide my
hand over a sensor(about 0-10cm) then led turns on and when i slide again it turns off. Basically i can use same code but how i can detect hand?