Arduino frequency counter

Or connect your counter input to the T1 pin and use the 16-bit hardware timer 1 to do your counting. Don't forget to install an overflow interrupt handler. You can similarly do period measurement by connecting your signal to ICP1 and clocking timer 1 from the CPU clock. It requires half an hour poring over the datasheet, but the code is pretty simple.