An auto-focus system based on the moiré effect and the P control method is presented. First, a collimated laser beam passes through a focusing lens and falls incident on the surface of the sample. The deviation of the angle of the light reflected back is proportional to the defocus distance from the sample. The reflected light then passes through two spiral gratings, where three types of moiré patterns are observed and received by a linear CCD. A new formula is derived for finding the focus value (FV) in order to calculate the spiral angle of the moiré pattern and to determine the defocus distance from the sample. The results show that auto-focus should be achieved in a very short time by means of the defocus distance calculation and P control method.