Accumulating error over time
The integral term addresses proportional control's steady-state problem directly by keeping a running sum of the error over time, scaled by a gain Ki. Where the proportional term only looks at the error right now, the integral term looks at the error's entire history since the loop started, or since it was last reset. If a small error persists tick after tick, that accumulated sum keeps growing, and because the integral correction is proportional to that growing sum, the correction itself keeps increasing even while the instantaneous error stays small and unchanging.
This is exactly what's needed to beat a constant opposing force like gravity or friction. Where a proportional term alone gives up with a residual gap because its correction shrinks along with the error, the integral term keeps pushing harder for as long as any error remains, because it's responding to the accumulated total, not the instantaneous size. Eventually the accumulated correction grows large enough to fully close the gap, which is why adding an integral term is the standard fix for steady-state error.
