The magnetic field is generated by a conductor carrying an electrical current or, more precisely, by the charges being moved therein. A single wire coil is all that is required, but often several coils are used. The number of windings per coil is also significant for the magnetic field. The more windings a coil has, the greater the magnetic field it generates because the fields in the individual windings group together to form a single cumulative field.
Due to the fact that generation of the magnetic field depends on the introduction of electrical current, the benefit of using electromagnets lies in the fact that, in contrast to continuous-action magnets, the magnetic field can be controlled or regulated.
To determine the direction of the lines in a magnetic field, you can employ what is known as the 'right-hand rule'. The trick here involves the user visualizing the conductor in such a way that the thumb points from positive to negative pole, while the extended index finger (90° to the thumb) points in the direction of the Lorentz force while the middle finger, also extended at 90°, points in the direction of the magnetic field.