---
If it is a switch type (output is active if there is a field of the appropriate orientation): tie the output of the sensor to an input that can trigger an interrupt. Have a counter (global) that the interrupt routine increments or decrements (as appropriate based on direction) each time the interrupt is triggered. If the sensor needs to have a response, respond in the interrupt handler. The counter will need to be declared as volatile, and can be read anywhere in the code as a position.
----
If it is analog output, tie it to a comparator input and use the comparator to trigger the interrupt.