Hi everyone.
I am trying to recreate Bill's PWM fan controller but with an Arduino Uno Nano ESP32 instead of the Seeed but keep getting compile errors around the pwm configuration viz. ledcAttach and ledcWrite as follows -
------------------------------------------------------------------------
Arduino: 1.8.19 (Windows 10), Board: "Arduino Nano ESP32, With FAT partition (default), By GPIO number (legacy), Normal mode (TinyUSB)"
C:\Users\User\AppData\Local\Temp\arduino_modified_sketch_885013\sketch_dec16a.ino: In function 'void setup()':
sketch_dec16a:26:5: error: 'ledcAttach' was not declared in this scope
ledcAttach(PWM_PIN, PWM_FREQ, PWM_RESOLUTION);
^~~~~~~~~~
C:\Users\User\AppData\Local\Temp\arduino_modified_sketch_885013\sketch_dec16a.ino:26:5: note: suggested alternative: 'ledcAttachPin'
ledcAttach(PWM_PIN, PWM_FREQ, PWM_RESOLUTION);
^~~~~~~~~~
ledcAttachPin
exit status 1
'ledcAttach' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
----------------------------------------------------------------------------------------
The more solutions I try from online reading regarding which commands have been retired and replaced and for which board etc. etc more confused I get (sorry, beginner). I guess it's something to do with the different board but am stuck as to what to try next.
I would be grateful if anyone could guide me regarding what changes I would need to make to the two sketches involved to accommodate the different board and where I might find a cogent explanation of the whys and wherefores.
Thanks and happy holidays to all.
David
Have you seen the info that contains:
The error 'ledcAttachPin' was not declared in this scope occurs when using the ESP32's LEDC (LED Control) API in Arduino IDE, typically due to changes in the ESP32 core library. Starting from version 3.x of the ESP32 library, the ledcAttachPin and ledcSetup functions have been replaced with a new API.
also:
The new API combines ledcSetup and ledcAttachPin into a single function called ledcAttach. Update your code as follows:
Corrected Code
Alternative: Downgrade ESP32 Core Library
If you prefer using the older API, you can downgrade the ESP32 board library to version 2.x via the Arduino IDE Board Manager.
By updating your code or reverting to an older library version, you can resolve this error and ensure compatibility with your ESP32 projects.