First step is not really code related but conceptual.
The motor has only one control "speed" so here speed = intensity.
Perhaps the pot could represent 0 to 100% max speed.
If the pot were at 100% the system would act as it does not.
If the pot were at 50% the system would essentially change the speed at each distance to 1/2 of what it would have been if the pot was at 100%