Speed sensor - Hall effect, Digital Pin?

I have an old hummingbird trolling indicator, I want to use in my project. I have pulled it out of the boat and done some testing/research. If I put 5V into the sensor from my Arduino, I can rotate the wheel (see attached photo) and Read a range from 0 to 0.68 V on the output of the sensor. I did not think that .68 V was enough to trigger a high value on a digital pin, so I have been trying to read it with an Analog pin: Here is my code (it doesn’t work) If I could use the Output of the sensor on a digital pin, then just count the HIGHs it would be a simpler code. I am trying to read the 133 off of the Analog pin, and be sure that I do not get double reads, by comparing it with the old value. Any Tips??

void setup() {

void loop() {
  int revs = 0;
  long endtime = millis() + 500;
  int count = 0;
  int value = 0;
  int old_value = 0;
  do {
  value = analogRead(A0);
  if (value >= 130 && value != old_value){
  old_value = value;

  } while (millis() < endtime);
  revs = count / 500; 
  Serial.println(revs, DEC);

I suggest you add some hysteresis by setting upper and lower threshold levels, rather than just one at threshold 130. Say 70 and 100. Wait for the reading to go above 100 and count a pulse when it does; then wait for the reading to go below 70. Then back to the beginning.

Two other possibilities:

  1. Use an op-amp or comparator with a little positive feedback to convert the 0.6v input into a nice 5v square wave, then you can feed that into a digital pin.

  2. Feed the signal into pin AIN0, set a reference voltage on AIN1 from a voltage divider, and program the analog comparator in the mcu to compare them. You can have the comparator generate an interrupt. However, if the input signal isn't clean, you could get multiple interrupts per input pulse. To avoid this, you could introduce some hysteresis by having two different references (you'd need to use a third pin).

The code needs to move on once an edge is detected, not continue to increment the counter while the input is high!!

long endtime = millis () + 500L ;
while (millis () - endtime < 0L)   // correct end test using subtraction.
  while (analogRead (0) <= 140) // wait till high
  count ++ ;  // step the counter and
  while (analogRead (0) >= 120)  // wait till low

I’ve added some hysteresis and corrected the end test so it works whatever the sign bit of the millis() value is.