Problems tracking pin state with Switch statement

Also, can you estimate the duration of the shortest encoder pulse that you want to be able to detect i.e. based on the speed you'll be turning the dial at, and the encoder resolution?