diff --git a/libraries/ESP32/examples/AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino b/libraries/ESP32/examples/AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino index aae974ac..a4f2e5b4 100644 --- a/libraries/ESP32/examples/AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino +++ b/libraries/ESP32/examples/AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino @@ -28,8 +28,8 @@ int fadeAmount = 5; // how many points to fade the LED by // Arduino like analogWrite // value has to be between 0 and valueMax void ledcAnalogWrite(uint8_t channel, uint32_t value, uint32_t valueMax = 255) { - // calculate duty - uint32_t duty = (LEDC_BASE_FREQ / valueMax) * min(value, valueMax); + // calculate duty, 8191 from 2 ^ 13 - 1 + uint32_t duty = (8191 / valueMax) * min(value, valueMax); // write duty to LEDC ledcWrite(channel, duty);