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);
}
}