Reading signal frequency

the original code is from here

If you are measuring a signal with sufficient swing (that it will trigger a counter click), all you need is a small resistor + the mcu.