IR sensor as proximity sensor

I have a TCRT5000 that I want to use like a proximity sensor to detect rotary RPM of a drill pipe, eventually wirelessly. I am trialing it out at the moment and have a single target that the sensor recognizes high/low as it passes. The problem that I am having is when I am outputting the high/low pulse to the box that I am using to display RPM as the RPM increases it seems like either the input or output is not fast enough to keep up with the speed of the pulses and it throws my readings all over the place. Am I maybe using the incorrect commands? I am basically learning Arduino just for this project. Below is the Sketch for the trial. Thanks for any help that anyone can give.

Regards,

Mike

// ******************************************
// Global variables Declaration - Mapping physical sensors connections to Arduino digital PINs
const int proxInput=2;
const int proxOutput=13;

void setup() {
pinMode(proxInput,INPUT);
Serial.begin(9600);
pinMode(proxOutput,OUTPUT);
}

void loop() {

Serial.print("IRSensorip ");
Serial.println(digitalRead(proxInput));

if(digitalRead(proxInput)==1)
{
digitalWrite(proxOutput,HIGH);
}
else{
digitalWrite(proxOutput,LOW);
}

}

Do you have a pullup resistor (10k) from pin 2 to Vcc ? If not, change:

pinMode(proxInput,INPUT);

To:

pinMode(proxInput,INPUT_PULLUP);

What RPM is the drill pipe running? Try:

digitalWrite(proxOutput, digitalRead(proxInput);

Please post your wiring diagram with pin numbers and voltages.

JCA34F:
Do you have a pullup resistor (10k) from pin 2 to Vcc ?

No resistor but it works except that it doesn't seem to be reading or outputting properly, for example, I am spinning at 100 RPM and increase to 150 RPM, the pulses start outputting so that they appear to drop then go up and then stabilize. I.E the RPM tracker that I am using goes from 100 to 80 to 160 and finally to 150. Could it be that the system is not fast enough to process the "on/off" signal fast enough?

JCA34F:
Do you have a pullup resistor (10k) from pin 2 to Vcc ?
What RPM is the drill pipe running?

About 150 RPM but it fluctuates.

JCA34F:
Please post your wiring diagram with pin numbers and voltages.

I don't have a diagram handy at the moment but can get one.

What were the results from following the directions as posted in reply #1?