The problem of constructing the control maximizing or minimizing the deviation of the first (upper) part of a plane two-component pendulum for single or several semicycles of oscillations is solved. The intercomponent angle is considered as the control parameter which can be changed in the given limits. The equation of motion contains both the angle and its derivative that makes difficult solving the problem. The change of variables allows to exclude the control derivative from the equation. Thereafter the optimal control is constructed as the feedback. The results of numerical investigation are given.