Electromagnetic fields

Oersted discovered a connection between electric and magnetic fields. It turns out that a moving electric current produces a magnetic field, and a moving magnetic field produces an electric field. When electric current goes through a straight conductor, a circular magnetic field is produced:

Straight conductor coming out of the page (left) and going into the page (right)

You can remember this with the right-hand rule: your thumb is the electric current (using conventional current—positive to negative) and your fingers curl to indicate the direction of the magnetic field.

For a solenoid (coil of wire), the opposite happens. The conductor is circular and the magnetic field is linear:

Magnetic field in and around a solenoid (Wikimedia Commons)

You can use the right-hand rule for this as well. Your fingers curl in the direction of the conventional current, and your thumb points toward the north. Inside the solenoid, it might look like the field lines are going from south to north, but really they are going from north to south like usual if you look at the way they curve around the outside.