How it works

Generating an Electric Field

Electric charges produce electric fields. If an electric charge were to move, the field would move with the charge. However, the field at a distance form the electric charge does not change instantaneously. the effect of moving an electric charge has to first propagate to the distance. It does so at the speed of light.

Generating a Magnetic field

A steady moving electric charge (current) produces a magnetic field perpendicular to both the direction of motion as well as the normal of the current carrying surface. This can be visualised simply by the right hand rule. For a current traveling in the direction of the right hand thumb, fingers wrapped around the wire would represent the direction of the generated magnetic field.

http://www.school-for-champions.com/science/magnetic_field_moving_charges.htm#.U3MmtPldXiI

If the current varies with respect to time, then the magnitude of the magnetic field will also vary in time. The changing strength of the magnetic field will propagate away from the wire at the speed of light. If the current oscillates in a sine pattern (alternating current), then the strength of the magnetic field will also oscillate in a sine pattern, propagating normal to the wire surface.

http://micromachine.stanford.edu/

Note: The sine wave is not traveling through space. It represents the magnitude of the magnetic field at a fixed location as it varies in time. The magnitude of a magnetic field will actually drop off at a rate of 1/r^2, where r is the distance away from the current carrying wire.

Putting it all together

A moving electric charge produces both an electric and magnetic field. The charge's motion produces fluctuations in the respective fields. These fluctuations propagate outwards at the speed of light. When the driving force for the charge is a sine wave, the produced fluctuations are also sine waves. The frequency of the driving force determines the frequency of the electric-magnetic fluctuations which can then be interpreted as electromagnetic waves.

Wikipedia: Electromagnetic spectrum

Interacting with a magnetic field

Moving a wire through a static magnetic field, or creating a changing magnetic field around a static wire will induce a current in the wire. The type of change will determine the type of induce current. If the wire moves at a constant rate, or the magnetic field strength changes linearly a direct current is induced in the wire. However, if the wire moves back and forth, or the magnetic field oscillates an alternating current is induced in the wire.

Note: The alignment of the wire and the magnetic field are important. Magnetic flux is described by ΦB = B cos(θ) A , and thus maximized when θ = π/2.