Electromagnetism was discovered by accident in 1821 by the Danish Physicist H.C. ěrsted. Electromagnetism is used both in the conversion of mechanical energy to electrical energy (in generators) and in the opposite direction in electric motors.
        In the picture below an electric circuit with a coil of insulated copper wire is shown, winding around an "iron" (magnetic steel) core. Click the switch in the picture to turn on the (direct) current and watch what happens.
Experimental setup picture