analogWrite() not working for some reason?

I have a program that the instruction analogWrite() brings up the error
'analogWrite' was not declared in this scope
when I click on compile.
So I loaded the analoginoutserial sketch from the analog section of examples and get the same error?
Any idea what I am doing wrong?
I am using arduino IDE 1.8.13.

ADD. seems the ESP32 feather doesn't use analogWriter? it works when I choose a nano? Does the ESP32 feather have an alternative?

Seems it not in the package, needs an extra library to add this.

Arduino site search on eps32 pwm... lots of articles!

For something small, I would bit-bang but here's a bit about the needed lib.

There is a different way for ESPs that replaces analog write() to create PWM
.
Here is a tutorial (you'll find more if you search the internet for "analogWrite ESP32")

And this seems to be a very comprehensive explanation (see that page also for other issues around the ESP32, e.g. tone() function)

Thanks for the replies guys seems a lot of reading ahead :face_with_head_bandage:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.