Simple Speed question - Mapping PWM values
The analogWrite() function takes a value that is between 0 (fully off) and 255 (fully on).

Your value of 150 to 240 is a value within that range of 0 to 255 and represents a percentage of the "on time" of the PWM signal.


(150 / 255) * 100 = 58.8% on time
(240 / 255) * 100 = 94.1% on time.


You seem to have an "input value" of between 0 and 9 inclusive.  Let's call this value "i".  You want an output value, let's call it "o".

The instructions say "0 to 9 times 10 plus 150 to get a range of 150 to 240". That is simple enough to convert to a formula.  0-9 is i, remember:


o = i × 10 + 150


If i is 0 then o = 0 × 10 + 150 = 0 + 150 = 150.

If i is 9 then o = 9 × 10 + 150 = 90 + 150 = 240.

As Ignacio mentions, the Arduino API has a map function which is meant to be used for this kind of thing;

o = map(i, 0, 9, 150, 240);


However: the map() function is quite heavyweight since it is designed to be a generic mapping function for scaling values. Doi g the calculation manually will always be far more efficient since map will use steps and calculations that are not really part of your needed result. It's a bit like the differende between 1 + 2 and 1+ 5 - 3 + 2 - 4 + 2. The result is the same, but one is far simpler to calculate than the other.