
A common electric guitar pickup has a magnet and a coil of wire. The magnet creates a field around the steel strings. When a string vibrates, it changes the amount of that field passing through the coil. That makes a small voltage that changes as the string moves.
How does that become the sound you hear?
The voltage from the guitar goes to an amplifier. The amplifier makes the signal strong enough to drive a speaker. The pickup can detect the string through its magnetic field, even when the unplugged guitar sounds quiet in the room.
Why does the pickup’s location change the sound?
A string doesn’t move the same way along its full length. Near the bridge it usually moves less and the pickup hears a different mix of vibrations than it does farther up the string. That’s part of why switching pickups changes the sound.
For more on how changing magnetic fields can produce voltage, see Basics of Electric Utilities 101.