Magnets work by generating magnetic fields through the motion of electrons within their atoms. The magnetic field is strongest at the poles of the magnet and opposite poles attract while like poles repel. There are two main types of magnets - permanent magnets made from materials with natural magnetic fields like iron, and electromagnets which use electric currents to magnetize otherwise non-magnetic materials like copper or steel. Magnets are used in many applications including compasses, speakers, motors, generators, MRI machines, hard drives, and toys.