Using Hall Sensor(TLE-4905) with Arduino Mega

it prints only zeroes in the output.

What is your input?

Before trying with the hall sensor, use the test I suggested with a pulse from tone() jumpered from an output pin to your input pin 47.

I think the pin number in pinMode is not right..

Pin 47 should be correct.