Traditional pulse width modulation (PWM) produces harmful ripple, which will interfere with other circuits. It is very unfavorable for many applications where high accuracy is required. A digital PWM scheme based on code technique is proposed and it can significantly reduce the ripple. The scheme can be expressed as:the PWM pulse sequences are evenly distributed throughout the PWM cycle. The most ideal situation is up to a single pulse level. Theoretically, there is a strong positive correlation between the output ripple and the amplitude of each harmonic of the signal, in which the ripple generated by fundamental and the second harmonic wave is the most significant. More deep analysis shows that with the scheme based on code technique, the ripple can be reduced to the minimum order of digital PWM. Preliminary experiments show that the technique is useful.