<h1>Magnetic Levitation (1 inch gap, stable, low cost)</h1>
[video width="1280" height="720" mp4="http://johann.langhofer.net/wp-content/uploads/2018/04/VID_20180418_2122030.mp4"][/video]

I've found a simple solution for the magnetic challenge in order to get a stable levitation. After several experiments and a lot of research on the WEB I came up with a solution using a handful components, more particularly, only five electronic parts are needed, a power supply, an arduino, a coil, a MOSFET and a hall-sensor. With a very small piece of software running on the arduino, the magnetic cubes can be hold in a very stable position. But wait, it wasn't so easy, I've got several issues and finally run into a serious problem...

Lets start with the big picture: an electromagnet with a coil and an iron core on the top attracts a floating magnet, a  hall sensor reads the magnetic strength of the gap between the two magnets and controls an electronic switch at the bottom which in turn powers OFF the coil if the strength exceeds a certain value (threshold) and powers ON if the strength falls blow this threshold. The threshold is exactly the line, where the sum of the up-pointing forces are in balance with the gravity of the floating magnet.

<img class="alignnone size-full wp-image-588" src="http://johann.langhofer.net/wp-content/uploads/2018/04/bigPicture1.jpg" alt="bigPicture1" width="510" height="616" />

&nbsp;

So what is the main problem trying to keep a magnet in a constant position from the pulling/pushing electromagnet? Stability is the answer. Given a good threshold value (up-pointing forces &gt; Gravity and "Magnet force" &lt; Gravity) there is no chance to keep the system stable. Even if you're trying to switch the electromagnet with high precision and high frequency and even if it seems it's stable, after some seconds, minutes or more the system will start oscillating an turn out of control.

Useful components:
<blockquote>Arduino Mini, Nano, Mega, laser 405nm
RaspberryPI I, II
WLan ESP8266
and much more.</blockquote>
[supsystic-gallery id=5 position=center]