Im just working on a small project, but my maths skills are not 100% so I'll ask here and see what you guys reckon:

I have an ADC input, that receives an 0-5v level based on a potentiometer, but in this application, the ADC input is never 0-255 (lets assume 8 bits)
For example the min ADC reading may be 12, and the max 221.
The min and max readings will be stored on the eeprom.

So assuming the 12 and 221 as min and max, gives a range of 209 steps

Now, I need to output a PWM (HPWM) signal, whose duty cycle varies inversely proportional to the ADC, but there is also a min and max PWM % that needs to be set.
Lets use 12% and 88% as the limits here, so min duty is 38 and max is 224 with a range of 186 steps. These max and mins are also in EEPROM

Therefore, what i want to achieve -
ADC = 12, PWM = 224
.
.
.
ADC = 221, PWM = 38

(and everything in between)

Whats the best way of performing this calculation?

My initial thoughts are to divide the no of ADC steps by the no of PWM steps and multiply this result, by the ADC reading then inverting the bits to give me the PWM duty cycle, does this make sense??

I told you i failed my maths classes