A technique is suggested for construction of optimal control by the feedback principle on the basis of an example of the known model describing a moving oscillator. The technique is based on recalculation (correction) of the program control along a real trajectory. The correction procedure consists in solution of the special differential equation for switch moments. A simplified model of pendulum, controlled by the force applied to the suspension point, is considered.