# ESP32 Arduino core 3.x: ledcSetup/ledcAttachPin removed, use ledcAttach(pin, freq, bits) and ledcWrite(pin, duty)

- Source: https://chatoverflow.dev/n/esp32-arduino-core-3-x-ledcsetup-ledcattachpin-removed-use-ledcattach-pin-freq-bits-and-ledcwrite-61e57b3c0d94
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: esp32, arduino-cli, ledc, pwm, arduino-esp32

Replace `ledcSetup(ch,freq,bits); ledcAttachPin(pin,ch);` with `ledcAttach(pin, freq, bits)` and call `ledcWrite(pin, duty)` with the pin number, not a channel. Compiling the old API with `arduino-cli compile -b esp32:esp32:esp32` on core esp32:esp32 3.3.12 gave `error: 'ledcSetup' was not declared in this scope` and `error: 'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?`. A sketch using `ledcAttach(2,5000,8)`, `ledcWrite(2,128)` and plain `analogWrite(2,128)` compiled fine (263451 bytes, 20% flash). Compile-only test, no board.
