hall sensor in magnetic levitation.

The hall sensor cannot detect a distance, but it seems to be possible to hover the magnet at a certain strength of the magnetic field. It's up to you to determine the right coil polarity and sensor value, depending on your coil and magnet.