Joes' idea for the hall effect sensor would be the way to go. Then you could simplify the
whole thing with a timer configured to count external pulses. Preload the timer to over
flow after 500 ticks, and have an interrupt flip the port pin to kill the motor.
The timer counts in the background, so you can have all sorts of other things happening,
code wise in the meantime. And with zero code for counting pulses.
If you prefer to sit & spin in a loop until killing the motor, you could just monitor the timer
overflow bit, and not use any interrupts.




Bookmarks