Motor/ Voltage Compensation

Does anybody have a way to compensate for when the voltage to a motor decreases so that we can keep the motor output constant?

Are you trying to run the motor at a constant speed? You’ll want to use a sensor so you can tell what the speed actually is and increase the power if it is too low.

We have a guide on closed loop control which you may find helpful:
http://team2168.org/index.php/resources/programming/217-pid-control-tutorial