Dlloydev / ESP32-ESP32S2-AnalogWrite

ESP32 PWM, Servo, Easing and Tone. Smart GPIO pin management and advanced control features.
MIT License
100 stars 17 forks source link

If channel is already used analogWrite fails. #14

Closed ArminJo closed 3 years ago

ArminJo commented 3 years ago

It would be nice to be able to assign a ledc channel to a pin. I want to use pin 13 but Channel 0 and 2 are already occupied by another libraries and awGetChannel(13) returns -1. Is there a workaround / solution?

Dlloydev commented 3 years ago

Yes, by design analogWrite won't work on any pin that has been previously accessed (to avoid conflicts). However, you could try to free up pin 13 in setup ... first by using analogWrite(13, -1); then try using it with analogWrite(13, value); (for example).