@Rob: Good point. I hadn't thought of that.
@PeterH: I have found interrupts on the Arduino to be incredibly easy. However, it might be easier to poll it. Let me see...
const byte PulsePin = 2; // Or whatever
const byte ResetPin = 3;
static int PulseCount = 0;
static byte PulseState = LOW, ResetPulseState = LOW;
if (digitalRead(PulsePin) != PulseState)
if (PulseState == LOW)
PulseState = HIGH);
Serial.print("PulseCount = ");
PulseState = LOW;
if (digitalRead(ResetPin) != ResetPulseState)
if (ResetPulseState == LOW)
ResetPulseState = HIGH);
PulseCount = 0;
Serial.println("PulseCount = 0");
ResetPulseState = LOW;
You're probably right. That does seem a little bit simpler to understand. The only real advantage I can see of using interrupts in this case would be if the high time of the count pulse were very short. It's not likely to be an issue.