A motor — or a generator — requires some normal magnets and some electromagnets. The usual arrangement is to have a brushed commutator that both powers the electromagnets and switches their polarity as the motor spins. Permanent magnets don’t rotate and attract or repel the electromagnets as they swing by. That can be a little hard to visualize, but if you 3D Print [Miller’s Planet’s] working model — or just watch the video below — you can see how it all works.
We imagine the hardest part of this is winding the large electromagnets. Getting the axle — a nail — centered is hard too, but from the video, it looks like it isn’t that critical. There was a problem with the link to the 3D model files, but it looks like this one works.
You can really see how the brushes and commutator work to flip the current direction through the coils. Being a simple demo, the brushes are probably not as robust as in a real motor, but for understanding how it works, it is a great demonstration.
If you’d rather build a brushless motor, we’ve seen those before. If you want a brushed motor quicker with no 3D printing, you can build one with just 3 wires, but it is harder to see the brush in that design.