I am wanting to have a pulse counter that can read down to 10hz and up around 24khz. I would like it to be ISP, IC2, or with minimal wires to Uno. My input signals will be 0-5V. I would like it to operate with a 5V supply also. I plan to put it in a socket or through-hole not surface mount.

The solution with the minimum number of wires does not require any external chip. You can use the 16 bit hardware timer to count pulses. Arduino does not provide a simple interface to this but I have used the following code to count up to 64k pulses:

the sketch is based on standard code to access the 16 bit counter inside the Arduino chip. The technical details are in the datasheet section covering the 16 bit counter unit (section 16.5 in the latest version of the ATmega328p datasheet)

The count is stored in the TCNT1 register in the Uno chip. this line access this value: count = TCNTn;

Note that when compiled for the Uno the compiler will substitute TCNT1 for TCNTn. It looks a little complicated because the same code can be used on bot a Uno and a Mega even though these chips use different registers for counting.

This is just a counter, your sketch would control the length of the sample time by adjusting the duration between calling startCount and getCount. How were you intending to control the count duration if you used an external counter?

the library linked below is probably easier to use than the code posted above. It uses a similar technique for counting and has implemented use of another timer to gate the counter if that is what you want to do.

This is just a counter, your sketch would control the length of the sample time by adjusting the duration between calling startCount and getCount. How were you intending to control the count duration if you used an external counter?

Thanks again for the additional information and the link!

I was not sure how I was going to control sample times. I have done some looking for chips but, I had not figured out the control aspects of them yet.

I think calling startCount and getCount should be easy enough using micros() for precision so, I can handle that.

After some experimenting I have some results! I am enjoying learning how to use the code! I also have a couple questions.

I used a 4.56kohm resistor from pin 5 then connected it off and on to ground. If I keep pin 5 grounded through the resistor my result was "5" pulses for a 2 second sample time. However, if I worked the ground resistor to simulate pulses I got numbers that look acceptable for now.

Could my resistor value be too large? Besides needing to put the Serial.print messages outside any of the timers and removing the delay do you see anything I might have done wrong?

hello here is the count 78 here is the count 5 here is the count 5 here is the count 5 here is the count 152 here is the count 5 here is the count 5 here is the count 11 here is the count 9 here is the count 10 here is the count 12 here is the count 5 here is the count 5 here is the count 5 here is the count 5 here is the count 5 here is the count 6 here is the count 9 here is the count 5 here is the count 6 here is the count 9 here is the count 13 here is the count 23 here is the count 5 here is the count 5 here is the count 105 here is the count 5 here is the count 5 here is the count 5 here is the count 384 here is the count 100 here is the count 762 here is the count 5 here is the count

I ran your code on my Uno and for some reason I could not get any counts. I think there might be a problem in the loop but, I could not find it. I set-up a Mega "for a Frequency generator" with a multi-tone sketch to get samples from and with your sketch mixed with my sketch I did get results. However, it seems the minimum pulse count is 5. I get reasonable pulse counts while the tones are changing but, when the tones stop I get "5" until I restart the tones on the Mega.

hello here is the count 220 here is the count 849 here is the count 500 here is the count 546 here is the count 673 here is the count 1119 here is the count 1129 here is the count 707 here is the count 1085 here is the count 1288 here is the count 1330 here is the count 5 here is the count 5 here is the count 5 here is the count 5 here is the count 5 here is the count 5 here is the count 5

The last code works perfectly! It has a minimum count of 0 when no pulses are given and it seems to be reading correctly with changing frequencies. I have lowered the gatetime to 100ms and it works well that way also!

I will have to test on other things to find the best gatetime for each case.