Counting pulses and using them