From:
http://arduino.cc/en/Reference/AnalogWriteSyntax
analogWrite(pin, value)
Parameters
pin: the pin to write to.
value: the duty cycle: between 0 (always off) and 255 (always on).
Returns
nothing
So, why are you assigning the return value to a variable?
Exactly. analogWrite() doesn't return a value, it is a void function,
so there is no telling what you get for the assignment.
In the larger picture I do think that analogWrite() should check for >= HIGH
instead of == 255 to provide a "known behavior" for values outside the real range.
This may start to be an issue as people use hard coded numbers like 255, 1023, etc
or even mapping functions that return values outside the usable range on the
different "..duino" boards and the code starts to be used on different processors
since they all may not have the same range.
For this specific case, wouldn't it be easier to use absolute value: abs() instead of map() since
there is no real need for mapping?
--- bill