Print the octagon stator and dodecagon rotor. You can download the 3d printing files here.
Use a compass to determine the poles of your magnets and glue the magnets with the north poles facing outward. If your magnets are strong enough, the compass on some smartphones will show you the polarity of the magnets.
Press fit the bearing into the stator and then press the rotor into the bearing. I was pleasantly surprised how well the bearing press fit into the stator. When 3d printing, holes tend to want to shrink inward and end up smaller than expected so I usually oversize them a bit.
Cut 9 pieces of wire to 25 feet and wind them with a drill. Use a compass and a battery to determine the configuration required to give you the south pole at the head of the nail. Use a marker or heat shrink tubing to mark the negative lead of your electromagnets. Wrap the sections of the electromagnets with electrical tape where they will come in contact with the stator housing. This serves two purposes. It firmly secures the electromagnets in place and also insulates the housing from any heat the coil may produce. The coil pairs draw about 1 amp with the 5V power supply I am using. The transistors I chose can handle using a 12V power supply that the coils draw about 3 amps from. The problem with the higher voltage supply is that if I leave it running for a bit, the coils start to get warm.
I designed this to run on a 5-12VDC power supply. If you decide to stray off the beaten path, use Ohm's Law to determine what size coils you want. V = I*R
Remember, the fewer windings on your coil, the lower the resistance is going to be. If you are not careful, your coils will pull more current than your power supply or transistors can handle and bad things will happen.
Push the electromagnets into the stator until they're about 1/4" from the neodymium magnets. You can slide the electromagnets in and out as you wish, but I didn't want them too close because the nails will become magnetized much faster. That's the downside of using the nails. The motor will still work once they become magnetized, but it will be less efficient. Welding rods are a good alternative to the nails if you have some laying around.
Wire up your coil pairs in series and connect them so that all the south poles of the electromagnets face inwards. The resistor I used in the schematic is a 1k resistor. The purpose of this is to prevent the digital pin from "floating" high when in the off position. Again, make sure to use a transistor capable of holding up to the current that your coils will be demanding. Notice that there isn't a diode to protect against the back emf from the coils. I don't need them because the back emf will be rather low at 5V and I chose pretty beefy transistors that can handle 8A and 40V. It is also worth a mention that you should usually use a current limiting resistor at the base of a transistor but in this case, the arduino digital pin doesn't supply enough current to damage the transistor.
Download the source code for this project here. Load the source code to you arduino and you're ready to go!