I am frustrated! I have seen lots of posts on the web for how to do it. Nobody ever mentions the header files, or if they do- the code doesn't compile. I have TCP/IP working UART comms and a bunch of other stuff, but...
There's the Ledc library, for which I've tried several header files (some didn't exist with the libraries I've downloaded- and I won't mention those). There's the "tones" library, and "Tones32", couldn't make those work (with decades of embedded systems experience). I read that some of the Ledc functions have been renamed from v2 to v3 of whatever library that is supposed to be.
What is the include file, and a couple of related function names that I can research and actually use? Should I just talk directly to the hardware by writing original code and forget the libraries? I am attempting to use an ESP32WROOM board for this.
Here are some of the current errors I am getting (but these are just with the latest attempts):
//#include "driver/ledc.h" #include "esp32-hal.h"
.... error: 'ledcSetup' was not declared in this scope
69 | ledcSetup(PWMChannel, PWMFreq, PWMResolution);
| ^~~~~~~~~
.... error: too few arguments to function 'bool ledcAttach(uint8_t, uint32_t, uint8_t)'
71 | ledcAttach(LEDPin, PWMChannel);
The LEDC API has been changed in order to support the Peripheral Manager and make it easier to use, as LEDC channels are now automatically assigned to pins. For more information about the new API, check LED Control (LEDC).
Thanks for the link- it sheds some light on why things might not be working. But I'm still stuck. (I've written in C, C++) but I don't know if the Arduino IDE can use the raw header files - it seems like it can't but it could be because I am using the wrong versions (I don't get compiler errors in them).
that's the hardware. When you compile, your code + the arduino core goes onto the board.
Your IDE could be configured with ESP32 core version 2 or 3. If you had the older version 2, probably you'll find that the libraries / tutorial you were looking at will work.
I guess main.cpp isn't stored locally. But I followed the link you gave me, found the ledc stuff, and was able to call one function without any compilation errors!!!
Now I know what to do about the other functions, so you fixed me! I should be beeping in a few minutes now.
I thought I had recursively searched all the Arduino dirs (Windows), but I hadn't. Thanks to you (again), I found it. My code compiles now, but no beeps. I should be able to figure it out fairly quickly though.