This ESP32 PWM example explains how to use the Pulse Width Modulation (PWM) with the ESP32-WROOM32 DevKit.
ledcWrite(pinChannel, dutyCycle);
ESP32 can generate PWM on all IO pins. In the ESP32 analogWrite will not work, is different than the Arduino Uno. ESP32 uses 8, 10, 12, 15-bit resolution for PWM generation PWM value. Arduino Uses 8-Bit Resolution i.e.PWM range is 0-254.