Measuring speed of a motor using IR sensor

Thread Starter

Ishan Jain

Joined Nov 12, 2016
100
Hello folks.

I am trying to measure the speed of a motor using arduino and IR sensor (E18-D80NK) but I am encountering some issues with my rpm readings.

1. The serial monitor shows an arbitrary value even if there is no motor in front of the IR sensor and the reading is like 1996, which is not acceptable for my project.

2. It shows the correct value for some time and then again shows different values.

I have attached the text file containing code that I am using for this. Please do have a look and tell me the solution for this.

Thank you.
 

Attachments

AlbertHall

Joined Jun 4, 2014
12,346
Your code for reporting RPM won't work as you expect. 'refresh' is never given a value. Try the code below instead:
Code:
if( ( millis()-refresh ) >= 100 )
{
refresh = millis();
Serial.println(rpm);
}
 
Top