Infrared Sensor State Change

So I'm doing a project and I need to make a state change detection infrared sensor that can "sense" and recollect the data in a specific period of time before resetting again. Basically I need to do a tachometer with this sensor but I'm having difficulties making the program.

My program is currently as follows:

int rpm=0;
float t=0;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(9,OUTPUT);
pinMode(A5,INPUT);
}

void loop() {
// put your main code here, to run repeatedly:

t=t+0.05;
if (V>2.00){
rpm=rpm+1;
}

else if (V<=2.00){
//tt=rpm;
rpm=0;
}
tf=60*tt/t;
Serial.print("RPM = ");
Serial.println(rpm);
Serial.print("Time = ");
Serial.println(t);
//delay(200);
}

  1. Use code tags.
  2. What is the question? (Are you looking for someone to write the code for you?)

I'm just looking for some direction to correctly make the code. Currently my code starts counting when there's something in front of it, I want my code to count when something passes in front of it not when there's something in it.

The problem isn't your code but how you're using the sensor!

How so?

Check out there: Digital Tachometer (RPM) using IR Sensor with Arduino

What is the sensor sensing? What range of RPM are you expecting? Which Arduino?

The sensor is sensing the time count a propeller is spent in front of the sensor, instead of how many revolutions this propeller does. As for the motor its a generic DC motor.

So, are you using a "gap" sensor and trying to count the blade tips passing through? Again, what RPM?

OK, What is the propeller blade width and what is the approximate angular velocity?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.