strange readings with hall sensor

I'm making a pov with arduino; instead of buying a new hall sensor(to see when the weel is in position 0) I took one from my bike (those that measure your speed ...); Cut off the sensor it has 2 wires (red black) I put it in analog1 and 3.5V;
easy code to see if it was working:

const int sensor = A1;
int sensorval = 0;
int val = 0;
void setup(){ 
sensorval = analogRead(sensor);
Serial.begin(9600);
}
void loop(){  
 sensorval = analogRead(sensor);


  Serial.println(sensorval);
}

when the sensor is away from magnet it give random values, mostly 0 or 1024 but also some in the middle, but when there is the magnet the value stops in 700 (more or less);

I used it in digitalread and the value changes randomly between 1-0 without magnet and stay 1 with;

on analogread i creted a map with 3 values(1-2-3) hoping to have 1 or 3 without magnet and 2 with, but it didn't work;
I used some resistors just to see but nothing.

The sensor is from a bike so I don't know anything about it.

Can someone please tell me why it happens? When it was on the bike it worked well.

P.S.
That's my first post, so sorry if I broke some rule or stuff of the forum, even if i red the tread;

bye

Sounds like your "hall effect sensor" is actually a magnetic reed switch. Try treating it like a pushbutton: include a pull-up or pull-down resistor so the input is not left floating when the switch is open.

Ok thanks;
I watched what a pull-up is, and I got it;but all the tutorials use the 4 pin arduino button; I have just 2 wires, where do I connect ground?
I tried some combination but I just got 0 all the time.

I have( my first scheme ever draw)

input___________________
I
SENSOR
5V____________________I

then I tried

input___________________
I
GND-------------------------- I
SENSOR
5V____________________I

input___________________
I
SENSOR
GND__________________ I
5V____________________I but I got only 0

then I put a diode on the second ground but nothing
can you help me?
bye

The switch needs to be on an i/o pin, with the other side to either 5V or Ground depending in if you want the closed switch to cause a high or low.

Have a look at the attached pic.

I changed the scheme I wrote, because it was wrong (I did connect the sensor to input, not so stupid)
tomorrow I will try your suggestion

ondsinet:
all the tutorials use the 4 pin arduino button; I have just 2 wires, where do I connect ground?

The four pins of the typical tactile button are just two connections. Two pins go to one side of the switch and two pins go to the other side of the switch.