Let there be light! In this tutorial we’ll build a basic magnetic levitator. This guide will go over some of the theory, how to use a magnetic field sensor, and how to use one to build a basic levitation circuit. Finally, we’ll go a bit further and build a wireless power floating light.

Theory Basics
When it comes to magnetic levitation, there are two kinds of levitation: attractive and repulsive. In this guide, we’re going to use an attractive levitation circuit as it’s a lot easier to get working. As we know, a magnet has two poles, north and south. Magnetic fields with the same polarity repel each other, whereas opposite poles attract. With magnetic levitation we need a fixed magnetic field, provided by permanent magnets, and a magnetic field that we can control to position the permanent magnets.

To create a magnetic field that can be controlled, we can use an inductor. Inductors store energy similar to capacitors; while capacitors store voltage in the form of an electric field, inductors store current by generating a magnetic field. Here we’ll be using the magnetic field of an inductor to interact with the magnets. With attractive levitation the inductor is used to oppose the force of gravity which then attracts the magnet up to the inductor.

If the magnet gets too close to the inductor, the magnet’s field strength will be strong enough to stick to the inductor, regardless of how much current is passing through the inductor. However, if the magnet is too far away from the inductor, the magnetic field strengths will be too weak relative to gravity to be pulled back up. So the trick is to find the window where magnet isn’t strong enough to pull itself up on its own, but with the attraction of the inductor’s opposing field the magnet is able to overcome gravity. To keep track of its position, we’ll use a magnetic field sensor, called a hall effect sensor.

Hall Effect Sensor
A hall effect sensor is a device that is used to measure the strength of a magnetic field. The output of the sensor is directly proportional to the magnetic field strength passing through it. The sensor we’ll need is the SS494B, which has an analog voltage output. There are other hall effect sensors that act as a switch and only turn on or off in the presence of a magnetic field. In the next section we’ll see how the sensor responds to the presence of our magnets.

Testing The Hall Effect Sensor
Let’s first test to see how the sensor works. With a breadboard, connect 5V to the supply voltage pin, ground to ground, and on the output pin, connect either an oscilloscope probe to watch the voltage change, or we can use a multimeter in voltage mode to watch the voltage change.

Without a magnet present, the output voltage sits at around 2.5V. With one side of the magnet, as the magnet gets closer to the sensor, the voltage decreases. If you flip the magnet around and bring it closer to the sensor, you’ll see output voltage increase. Make note of which side causes the voltage to decrease. It might help to make a mark with a permanent marker, which will be useful in our next test.”