Magnetic Pendulum




Introduction: Magnetic Pendulum

Here is a quick and simple project for a lazy afternoon. We are going to make a perpetual pendulum using Arduino and a few components. If you pack it nicely it will make a great decoration for your workshop or a nice gift.

Step 1: Parts

Here are the basic parts you will need:

  1. Arduino.I used Nano on a small breadboard.
  2. Coil. You can salvage one from a dead hard drive, or even make one, as described below.
  3. Acquire some magnets. I found some small neodymium 2x5mm disk shape magnets on eBay.
  4. 100Ω..1kΩ resistor.

You will need some additional parts to complete the pendulum. This is up to your imagination, but I will give an example.

Step 2: How It Works

Imagine a magnet passing over a coil. According to the Faradey's law of induction, the voltage induced in the coil is proportional to the rate of change of the magnetic flux through the coil. Without going into equations, the induced voltage will depend on the number of turns in the coil, speed of the magnet, magnet's flux density ("strength") and the size/shape of the coil. The induced voltage will look pretty much like the one shown above (or inverted, depending on polarity). The first, in this case negative, part is induced as the magnetic field is entering the coil (magnetic flux rises) and the second, in this case positive, part as the field is leaving the coil (magnetic flux decreases). When the magnet is right above the coil the induced voltage is zero as the magnetic flux is constant, since the magnet is neither coming nor going, and the rate of change (derivative) of the field is zero.

OK, enough with the science. What we want is to detect the second part of the waveform just when the magnet passes the center of the coil. Then, by turning the coil into electromagnet, we'll give the magnet a small push.

Step 3: Schematic

Connect the resistor and the coil in series between A0 and GND on your Arduino board. Do not worry about the coil polarity as the proper operation can be achieved later by flipping the coil or the magnet. The resistor value is not fixed, different values will change the force that the magnet will be pushed with (lower resistance - higher force). Although it might even work without the resistor if the coil resistance is high enough, I would not recommend going bellow 100 Ω and relying on Arduino's current limiting (or the lack thereof).

If you do not have a premade coil you can make one. Find some thin enameled wire and wind a coil using this calculator. Aim for couple of mH or more. Mine is about 2.6 mH, inner radius ~15 mm, approximately 250 turns of 0.14 mm wire.

Step 4: Code

The ADC is constantly sampling the coil voltage at 1 ms period. Once the THRESHOLD value is reached during the second, positive, part of the waveform the coil turns into electromagnet, pushes the coil for PUSH_TIME milliseconds and than goes back to sensing the voltage again. Here, it is important that the second part of the waveform is positive since we cannot measure negative voltages directly with the Arduino's ADC.

Set THRESHOLD low enough to detect the magnet as soon as it passes the center of the coil, but high enough to avoid false triggering by noise. Set PUSH_TIME to couple of tens of milliseconds.

Step 5: Completing the Pendulum

Here is one example how to complete the pendulum. Using a plastic cap, a wire, some cotton thread and an IC make a miniature swing. Place the circuit inside the box, glue the coil under the top side of the cap and cut a hole for the power supply. Using some LEDs, diodes and resistors make a small figure, give it a pair of magnetic feet and place it on the swing. Adjust the thread length and bend the figure's legs to position the magnets just above the coil. Plug the power in, give the figure a little push and enjoy the perpetual motion! In case it is not working reverse the coil or magnet polarity and give it another try, or play with THRESHOLD and PUSH_TIME values as described above.



  • Tiny Home Contest

    Tiny Home Contest
  • Audio Contest 2018

    Audio Contest 2018
  • Furniture Contest 2018

    Furniture Contest 2018

18 Discussions

I like how simple the circuit is. I'm wondering do we need to worry about the discharge from the coil after the pulse? Every other circuit that deals with coils or solenoids use some form of kickback diode. Would such a diode interfere with the detection of the magnet passing over the coil?

I prefer this simple design, but worried it will fry my arduino nanos.

1 reply

The microcontroller has internal clamping diodes that should be able to absorb the coil energy, so I would not worry about frying the board. However, for a peace of mind, you can add a small schottky diode, cathode to A0, anode to ground.

I like this but do you know if it is possible to get it to light up every time it passes its peek or the base

7 replies

You could simply use the pulse to the coil to light a Led.

The Arduino can be replaced with a couple of transitors and passive components.

Do you have more info on how this can be done with the transistors and passive components? Arduino is great, but it seems like overkill for many things.

Thanks! That's exactly what I was looking for!

Welcome. I use mine for a couple of projects and it runs for days or weeks on a set of batteries. I want to replace the 1 meg with a 1 meg potentiometer to get some control over the timing. I think that is the resister to replace.

You could also use the Adafruit Trinket or even an ATTiny45 or ATTiny85 if you already have a programmer.


1 year ago

Thanks for this. I use a two transistor circuit but want to use an Arduino.

Very nice! Love it. I'll make one. Thank you.

Awesome project and writeup!