Here is some very simple pulse counting code which has the proper handling of the transfer of data from the interrupt routine. It counts for one second, so rpm will be 30x the count with a two bladed propellor. With the lm393 boards, the most simple solution is to add a capacitor(100nf) between the digitalout/interrupt pin and ground. See this thread FC-03 and attachInterrupt() problems!?!? - Sensors - Arduino Forum
volatile unsigned long count = 0;
unsigned long copyCount = 0;
unsigned long lastRead = 0;
unsigned long interval = 1000;//one second
void setup()
{
Serial.begin(115200);
Serial.println("start...");
pinMode(2,INPUT_PULLUP);
attachInterrupt(0, isrCount, RISING); //interrupt signal to pin 2
}
void loop()
{
if (millis() - lastRead >= interval) //read interrupt count every second
{
lastRead += interval;
// disable interrupts,make copy of count,reenable interrupts
noInterrupts();
copyCount = count;
count = 0;
interrupts();
Serial.println(copyCount);
}
}
void isrCount()
{
count++;
}
Can you provide a schematic of your tcrt5000/lm393 breakout board?
If the simple capacitor doesn't work, we can provide debounced interrupt code, but try hardware first.