Making a magnetic levitation system with arduino
Your design is fundamentally a feedback control loop where the position is actuated by an electromagnet and measured by a pair of Hall effect sensors. At the core, such a design is practical but there are some critical details that merit close attention:


Your method for measuring the displacement of the magnet is a bit questionable here because the sensor will also be influenced by the electromagnet turning on and off. Even though you use two sensors to attempt to account for this, the cancellation is not perfect and thus you will have some component of positive feedback. Consider some other displacement sensor.
You are only allowing the coil to be on or off. This will make it much more challenging to stabilize. Consider an anlog current source for the electromagnet and a PID controller.
You are only sampling at 2-1000Hz. You may need to go faster than that. It depends on the other time constants in the system (which should be measured).
The magnetic system is far from linear. This further complicates control.


In short, it is possible but far from trivial.