I am using Allegro A1356 hall effect sensor to measure the distance between a permanent magnet and my hall sensor. I used the code here (http://playground.arduino.cc/Code/HallEffect). Seems that it's not working properly, it output 0 all the time. Did anyone ever use this sensor before? Could you help me out or kindly point me some directions?
Do you have a pullup resistor between VCC and PWMOUT on the chip? It should be around 1K. The PWMOUT pin sinks current when it's pulsing. So the pullup sets the voltage high on the PWMOUT pin (and your output) and when a magnet is placed near the chip the chip starts pulling the line low.
The playground page you have linked assumes a hall sensor with an analog output. Yours is a PWM output -- it's digital. You need to measure the length of the pulses in order to determine the magnetic field strength. This is typically done with the pulseIn() function. Your function call in your sketch is going to look something like:
unsigned long duration;
duration = pulseIn(hallsensorpinnumber, LOW, 10000);
Serial.println(duration);
If you're wondering why this is so hard it's because you purchased a pretty odd hall sensor.