AnalogWriteResolution error?

Hi, I was reading the reference for this function and saw this code:

// change the PWM resolution to 4 bits
   analogWriteResolution(4);
   analogWrite(13, map(sensorVal, 0, 1023, 0, 127));
   Serial.print(", 4-bit PWM value : ");
   Serial.println(map(sensorVal, 0, 1023, 0, 127));

https://www.arduino.cc/en/Reference/AnalogWriteResolution

Shouldn't be the value 15 instead of 127?

// change the PWM resolution to 4 bits
   analogWriteResolution(4);
   analogWrite(13, map(sensorVal, 0, 1023, 0, 15));
   Serial.print(", 4-bit PWM value : ");
   Serial.println(map(sensorVal, 0, 1023, 0, 15));

Adriano

Yes, I think so. It should be 15.

After 3 months the bug on the webpage is still present.

Why add the link"report error" if this will not be reported?

I have notified the Arduino developers of this issue: https://github.com/arduino/Arduino/issues/5428 They usually don't read the forum, which is probably why the issue has not yet been fixed. Thanks for reporting this issue Adrianotiger!

The example code on the analogWriteResolution reference page has now been fixed. Thank you Adrianotiger!