A motor is controlled by a closed loop or open loop system.
The theory behind control systems and how they control motors and other devices is the foundation of all modern mechanical systems. Using control system mathematics and theory, you can design systems that do nearly anything you want, to the granularity that you desire, in the amount of time that you desire. Control system theory can be broadly broken up into two major categories: open loop control and closed loop controls.
Open loop control is by far the more simple of the two types of control theory. In open loop control, there is some sort of input signal (digital or analog), which then passes through amplifiers to produce the proper output, and is then passed out of the system. Open loop controls have no feedback and require the input to return to zero before the output will return to zero.
In closed loop control, the system is self adjusting. Data does not flow one way, it may pass back from a specific amplifier (such as velocity or position) to the start of the control system, telling it to adjust itself accordingly. Many physical systems are closed loop control at the lowest level since the data about velocity and current position modify the output (also position) at consistent rate.
Open loop and closed loop control systems share most of their constituent parts. The first section of a control system is an input. This can be analog or digital, and can indeed take nearly any form imaginable. Some example inputs would be position, velocity, heat, or intensity of light.
Once the input passes into the start of the system, it undergoes amplification of various kinds. The two primary types of amplifiers are transfer functions and gains. Transfer functions modify the input in some way to put it into a format desired for output, and generally take the form of output (from the transfer function) over input (into the transfer function). Gains, on the other hand, are usually flat multipliers to increase or decrease the value of the signal.
The data leaves the system through the output, which is the end point of the signal. Sufficiently complex systems can be broken down into more simple inputs and outputs, and vice versa. For example, a very complex control system with multiple gains, transfer functions, and feedback can have it all simplified to a single transfer function, though it may be harder to understand the source of each mathematical section.
Finally, some control systems have disturbance, which is data that modifies or corrupts the signal in an unwanted way, and affects the output as such. Good control systems seek to minimize disturbance and keep the original input signal as pure as possible.
Closed loop control systems also have feedback. Feedback is data that is passed back from some point into the control system to another preceding point in the control system.