Noob Question: Using a hall effect sensor for getting the RPM

hi, i'm trying to get the calculate the RPM using a hall effect sensor. the current one i'm using is a linear hall effect sensor (Allegro A1104LLHLT-T). now, this my seem stupid, but i can't get the thing to work.

I've tried to understand every tutorial, but i can't get it to work. my problem right now seems to be with the connection, i'm connecting the 3 pins of the sensor to ground, +5v and analog INPUT 0. but all the examples are using attachInterrupt 0 which really doesn't make sense.

anyone could help? =(

but all the examples are using attachInterrupt 0 which really doesn't make sense.

Why doesn't it? The hall effect sensor outputs a digital signal every time the magnet comes close. Trying to read that as an analog value makes no sense.

Having the sensor output trigger an interrupt, which causes an interrupt service routine, which simply counts the pulse, does make sense. At least, it does to me.

Why does it not make sense/seem logical to you?

There are both analog and digital hall effect sensors avalible. The one you specified is indeed a digital sensor. I suspect your problem getting it to work is the fact that the output of that sensor is a open drain transistor and requires a external pull-up resistor. This can be satisfied with either a resistor of say 10k ohms wired between the arduino digital input pin and +5vdc or by enabling the input pin's internal pull-up resistor.

http://www.allegromicro.com/en/Products/Part_Numbers/1101/1101.pdf

Lefty

@PaulS, it does make sense now, i thought that it was suppose to be an analog value. lefty, pluging it into the analog input and reading the value i get a around 300, drops to 0 when i bring the magnet close. should this be the behavior?

lefty, pluging it into the analog input and reading the value i get a around 300, drops to 0 when i bring the magnet close. should this be the behavior?

No. As I said you have a digital sensor which should give you only a HIGH or LOW reading using a digitalRead() command. A LOW means it senses a magnetic field and a HIGH means it does not sense a magnetic field.

You need to activate the internal pull-up resistor for the digital input pin you decide to use. You do this in two statements:

pinMode(5, INPUT); // set the sensor input pin to input mode, use any digital pin you desire digitalWrite(5, HIGH); // this enables the internal pull-up resistor for pin 5

Lefty