How to sense current being used by motors
I have read about using a shunt resistor and an op comparator (LM311), but I don't understand how I would do that, or if its even the current way to measure.


The shunt resistor part is correct, it will crate a voltage drop that is proportional to the current that goes through it (and consequently the motor).
In order to influence the motor current as little as possible you want the shunt resistor the be of a fairly low value. Obviously the same shunt resistor value  will introduce a much higher voltage drop in a high current circuit compared to a low current one, so using 0.1 Ohm for 10A will drop 1v while it will only drop 50mV for 500mA

Feeding that voltage to a comparator can only give two states, one when the current is below a specific threshold and another one when the current is above the threshold, like an alert flag.
That is a useful configuration to implement a current limit but not to measure the current level.

On the other hand feeding the voltage to an opamp can amplify it and maintain a linear relation between the input current and output voltage.
A low side circuit using an opamp would look like



The gain of the opamp is set by the values of R1 and R2, calculated as \$Gain= 1+ \frac {R2}{R1} \$

As an example lets suppose that you use a shunt resistor of 0.1 Ohm. That will give a voltage output of 0-50mV (for 0-500mA). In order to get a better resolution in your ADC (assuming Vref=5v) you can apply a gain, lets say 80x (to leave some headroom) so that the output becomes 0-4v. Another option is of course to apply a lower gain and use a lower Vref for the ADC, this is up to you.



Note that the above method describes low side current sensing (ground side), there is also the high side current sensing (positive supply side of the load) which is more complicated and usually an IC solution is better suited. Refer to the following answers:

Hall-Effect-Based Linear Current Sensor ACS712
IMA138 shunt monitor, ZDS1009 current mirror

You can also read this related article Understand low-side vs. high-side current sensing