A wire carrying a current creates a magnetic field. This can interact with another magnetic field, causing a force that pushes the wire at right angles. This is called the motor effect.
The motor effect is used inside headphones, which contain small loudspeakers. In these devices, variations in an electric current in the coil of wire (solenoid) cause variations in the magnetic field produced by an electromagnet. This causes a cone to vibrate in and out. The cone's vibrations create pressure variations in the air and form sound waves, which travel through the air to the ear where we hear them.
Alternating current supplied to the loudspeaker creates sound waves in the following way:
a current in the coil creates an electromagnetic field
this electromagnetic field interacts with the magnetic field from the permanent magnet, generating a force which pushes the cone outwards
the direction of the current is reversed
the direction of the electromagnetic field reverses
the force on the cone now pulls it back in
repeatedly alternating the current direction makes the cone vibrate in and out
the cone vibrations cause pressure variations in the air, which are sound waves
To make a loudspeaker cone vibrate correctly, the electric current must vary in the same way as the desired sound.
The discovery of the electromagnetic effect led to electromagnets being used in many applications, including: