This is the underlying principle behind the current shunt. A current flows through a resistor, and the voltage ... consider a microcontroller used to control a DC motor with a transistor ...
There’s many different ways of measuring current. If it’s DC, the easiest way is to use a shunt resistor and measure the voltage across it, and for AC you could use a current transformer.