Go Down

Topic: Magnetic levitation (Read 26 times) previous topic - next topic


My New Arduino Book: http://www.arduinobook.com


Hi, im talking to you guys from Mexico. I tried to do this experiment at home, but it doesn't levitate. I also tried making different kinds of electromagnets but that was not enough. I don't know which the reason can be. I hope you guys can help me with this. Greetings.


Very cool!  :smiley-mr-green:  Where did you get the electromagnet?  I am posting this for my son and he wants to build a similar unit but doesn't know where to start looking for a suitable electromagnet.  (BTW, he is autistic so reading/writing is difficult for him but is brilliant in electronics and circuitry).  Thanks in advance!


Well, the one in the video looks like a solenoid with the plunger removed.

They're rather easy to find, and if you're mechanically inclined at all you'll know where hundreds are!

In cars alone:
Pretty much every emissions / vacuum / boost solenoid to control air/vacuum/boost
Power door lock actuators (some may be gear driven, but most are simple push-pull solenoids)
Air conditioning solenoids (in cars)

You can probably buy 20 of them at a junkyard for under $10 bucks, since it doesn't matter if the housing or nipples are broken off of them.

Any equipment that has the ability to turn on and off, let's say.. water or fluid as well.

A solenoid is an electromagnet wrapped in a metal can, with a hollow tube in the middle. The plunger is a steel shaft that sits in the tube, partially spaced out with a small spring.

When electricity is added, the plunger shaft gets sucked into the can, pulling the linkage it's connected to in with it.

Pull the plunger out, and put a bolt with a nut on one side, as the OP did (at least it looks like).

You can epoxy the hall effect sensor on the head of the bolt through the electromagnet.


Hi ea123, can you post the list of components you used?


Very cool!    Where did you get the electromagnet?

Hello, I bought the electromagnet and magnetic sphere here:


they sell a complete magnetic levitation kit (not based on Arduino) or single components.


very cool project!
... but... the code is no more available... (503 error)  =(


I have been trying to replicate this but am having some difficulty. I have the circuit nominally working, but I can not get it tweaked to levitate the magnet. Either the magnet drops to the base, or slams into the electromagnet ( I am using the same electromagnet, permanent magnet, and code presented in the OP, the hall sensor might be slightly different as I am using the A1321). It is easy to see that the parameters depend critically on the specific permanent magnet being used, the characteristics of the hall sensor, and the electromagnet.

I have tried different magnets, and different settings without success. In trying to be methodical, I run into the complication that the hall sensor itself picks up the signal from the electromagnet. So, trying to turn the electromagnet off and map hall sensor reading to distance from permanent magnet to electromagnet does not help, because that mapping will be distorted depending on the signal to the electromagnet. Another complication is that the permanent magnet is attracted to the metallic parts of the electromagnet so there is an uncontrolled attractive element that increases as the gap decreases.

Can anyone suggest a methodical approach to tweaking the set point, P-gain, D-gain, and I-gain to get this thing floating? Given that there are 4 parameters, and no real equations to guide, I am sort of at a loss at this point.



We are working on a similar project. Kindly let me know about the specifications of the coil used. We want to levitate a small steel ball of weight 0.3 g. I would like to know the voltage and current applied to the coil. Number of turns used. What core did you use for this ?


Is your code available? If it is there i didn't see it.





Hi could you please tell us the value of L1..?

Thank you.!


I'm curious, how stable is this? Has anyone ran it for long periods of time?


At some point, I will update mine to use a Hall sensor - I still have long term dreams of a planetarium ceiling populated with floating, rotating planets!

However, one power outage and it would be raining celestial bodies!

Not if they were tethered with a 'invisible' safety line attached to the ceiling. That would allow them to drop but not all the way to people level.


Go Up

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Note: this post will not display until it's been approved by a moderator.

shortcuts: alt+s submit/post or alt+p preview