In general, SPMs use a fine-tipped probe to scan across the surface of a sample. The probe interacts with the sample in different ways depending on the type of SPM:
STM: Utilizes quantum tunneling of electrons between the probe and the sample to produce an image. AFM: Measures the force between the probe and the sample to map out the surface topography.
The data collected from these interactions are then used to construct high-resolution images of the sample's surface.