In SPM, a sharp probe scans over the surface of a sample. The interaction between the probe and the surface is monitored and used to generate an image. In AFM, the probe is a cantilever with a sharp tip that interacts with the sample through forces such as van der Waals forces, electrostatic forces, and magnetic forces. In contrast, STM uses a conductive tip to detect tunneling current, which depends on the distance between the tip and the sample surface.