When you put the compass near the electrical wire with current flowing through it the compass did not point north.
Compass and electric current.
Now if we increase distance of magnetic compass from current the electric compass deflects less than before thus magnetic field becomes less as we move away from the wire a video explanation is given below what is electromagnetism it is branch of physics which studies phenomena of electrical current and magnetic fields.
Click the turn on button to connect the battery and create an electric current in the wire which travels from the positive to the negative terminals.
When a compass is placed on one side of the wire it will point in one direction.
When the current flows through the wire the compass needle aligns itself with the magnetic field created by the electrons traveling in the current rather than with the earth s magnetic field.
A compass will be most affected by the magnetic field of a current carrying wire when the plane of the compass is at 90 degrees to the wire and lest effected when the plane of the compass is in the same plane as the wire.
When you moved the compass near a bar magnet the needle pointed toward the magnet s magnetic field and not toward the north.
In either case the compass needle will follow the stronger magnetic field be that the magnet the magnetic field induced by current through the wire or the earth itself.
We can compare the electric current to the water flowing through the pipe.