Eliminating motor noise with hall effect sensor?
A cheap experiment might be to add some capacitance to the signal wire.  Doesn't matter if it goes to +5V or GND; it'll work the same either way.

Cutoff frequency = 1 / (2 * pi * R * C) where C is in Farads, R is in Ohms (10k as drawn at the moment), pi is 3.14159..., and the frequency is in Hertz (events per second).  Remember to keep the SI prefixes straight.

Keep a comfortable margin between the cutoff and your maximum expected frequency of teeth going by, and it should reject at least some of the motor noise that falls above that.



You'll also want to make sure that you're using a Schmitt Trigger somewhere between this filter and the interrupt, either built into the chip or an external schmitt inverter or something similar that requires a big change in input to actually change state and isn't just an analog amp with ridiculous gain.  Because you can't get rid of all the noise, the latter will still give you a bunch of interrupts as the signal transitions from high to low or vice versa; the former will wait for a more solid high or low before switching, which should reduce the number of transitions per tooth.



If you can get a reliable non-count between teeth and still see every tooth, but can't get exactly one count per tooth, then you'll have to do some debouncing in software.  The two ways that I like to do it are:


Periodically read the pin regardless of activity, slowly enough to miss the bouncing but fast enough to still be responsive.
Use a timer to ignore all transitions that are too close to the last one.  You'll still interrupt on all of them, but do nothing if it hasn't been long enough yet.


#1 works well for user interfaces, but I think #2 might be better for your situation.