Magnetic fields can be created by motions of electrical charges . The electromagnet is a device composed of a coil of wire that produces a magnetic field whenever a charge runs through the coil. The electromagnet Remember that Gilbert studied magnets in the 1500s. He found that if you stroke a piece of iron with lodestone then it will become magnetic. If you hammer iron then it becomes magnetic.
Lightning hitting magnetite turns it into lodestone.
Heating up a magnet causes it to lose its magnetism. Running a current through a coil was a new way to make a magnet. In addition, you could turn this magnet off and on at will. You could also vary its strength by varying the current. Many electric switches work from the electromagnet principle.