PWM and closed-loop control, from voltage to velocity
Most motor control starts with pulse-width modulation (PWM): rather than varying voltage continuously, the driver switches full voltage on and off very rapidly, and the fraction of time it's on (the duty cycle) determines the average voltage and therefore roughly how fast the motor spins or how much torque it produces. PWM is popular because switching a transistor fully on or off wastes very little energy as heat compared to a linear voltage regulator, which makes it efficient enough to drive real robot-scale motors without excessive cooling. On its own, though, PWM is open-loop: commanding a duty cycle tells the motor roughly what to do, but says nothing about whether it actually got there, since load, friction, and voltage sag all affect the actual outcome.
Closing that loop is where encoders come in. An encoder attached to the motor or output shaft reports actual position or speed back to the controller, which compares that measurement against the commanded target and adjusts the PWM duty cycle to correct the error, typically using a PID-style controller (assuming familiarity with that from PID & Feedback Control Systems). This is the difference between telling a motor 'run at roughly this duty cycle' and telling it 'reach and hold exactly this velocity or position, and correct yourself if something pushes back.' Encoders come in two main flavors: incremental encoders report relative movement (ticks since power-on) and need a reference point (homing) to know absolute position, while absolute encoders report a unique position value at every angle, even immediately after power-up, at the cost of more complex electronics.
