Camshaft sensor RPM Reading

Hello I am using the following camshaft position sensor for measuring the rpm and angle of the camshaft of my bike

For that i am using a 3 pin hall effect type camshaft sensor , the circuit diagram is attached below.

The analog pin Ao to which this circuit was attached was fluctuating a lot and i could not get any reading.

Kindly help me out on ho to get a stable signal from the signal wire to the arduino on the analog pin.ANd also how to measure the angle of rational and rpm.

There is a arduino code available to measure RPM in the following link

But this uses a digital input. How can i modify this code to suit my application?

Kindly help

Here is the camshaft whose angle I want to measure and also RPM. The image below is taken from the link:

Datasheet for the sensor? (analog or digital?, husteresis?, open-collector output ?, voltage out?)
If there is fast rotation, in must be interrupt-driven.

It is easy to count pulses (rpm)..
To read the angle (with no rotation) requires an other kind of sensor

Hello Sir, Sorry but there is no data sheet.I only know about the pins of the sensor. Actually this was the problem I was facing too.I only need an approximation of the rpm not highly accurate reading.

It looks like an analog sensor though.You can see the sensor diagram attached in my question.

One more thing, I am also connecting the signal wire to the arduino analog pin directly. The voltage supply to the cam shaft sensor is 12 volt and the gnd is also of the power source.

Should I connect the gnd to the arduino gnd ? And should i add something in between the signal wire and analog pin ??

Is it something like this ? :

It delivers a square wave output so you should probably read it on a digital pin and identify the pulses.
Can you power the device from the Arduino (5v) ?
If you must power it at 12 volts (which you cannot directly connect to an Arduino pin), then use a potential divider made out of 2 resistors to ensure only 5v is delivered to the Arduino pin.

The grounds of interconnected devices should usually be interconnected.

Yes sir , it looks like that only . I tried to run the read rpm code given in the arduino website , whose link I have attached in my question. But nothing got promoted out from the serial monitor . Although in this I case I supplied a 12 volt supply and try gnd was of the supply source not arduino.

Make gnd-lines common. AND !!! Add a serial resistor (1k+) on the signal line. This is important, else u'll fry the input pin (or chip)