Counting multiple pulse input

@allanba,
Can you post your final working code for future reference?