The atomic force microscope (AFM) is considered a powerful tool used for imaging at nanometer scale. The microscope tip has to go back and forth in a raster scanning motion over a substrate carrying the sample at slow rate to get enough accurate image of the sample. Many algorithms are designed to solve such problem by steering the tip along the surface of the sample. In the present work, a control algorithm is designed to steer the tip along the desired sample surface only. The scanning process is carried out simply, rabidly, and acquiring high resolution. The proposed algorithm depends only on the data coming from the vertical sensing device. The algorithm is tested for different samples and it is found to be ideal in imaging string-like objects, such as carbon nanotubes, nanowires, and DNA strands. The algorithm performance is accurate, reliable, and resolution is now a controlled parameter.