Hello,
Board: Arduino Nano ESP32
IDE: 2.3.4
Core: ESP32 3.0.7
Same behavior with ESP32 Core 3.1.1 after update and same behavior with Arduino ESP32 Core 2.0.18.
I stumbled across a problem with analogWrite.
Short story. I have programmed an eye blinker. It works with one instance. Then I created a second and third instance and suddenly the LEDs (pins) go crazy.
I suspected an error in my program, reduced everything, still have arbitrary pin function with several instances.
Only when I replaced analogWrite with digitalWrite did everything work as it should.
Now I have written a test program and see that analogWrite really has a problem. Not all pins are controlled. After the 5th led nothing happens, they stay off.
Same problem with ledcAtach and ledcWrite.
With DigitalWrite all pins are controlled.
Is the problem known? Is there a solution?
Additional question.
Why can't the pins D17 to D24 be used with analogWrite? I get a declaration error. I thought all pins are PWM capable?
// --- Arduino Numbers ---
unsigned pin [] {D1, D0, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13}; //, D17, D18, D19, D20, D21, D22, D23, D24};
// --- ESP GPIO ---
//unsigned pin [] {43, 44, 5, 6, 7 ,8 ,9, 10, 17, 18, 21, 38, 47, 48, 1, 2, 3, 4, 11, 12, 13, 14};
void pinDigital (void)
{
for (auto &p : pin) {
digitalWrite(p, HIGH);
delay(500);
digitalWrite(p, LOW);
delay(500);
}
}
void pinAnalog (void)
{
for (auto &p : pin) {
analogWrite(p, 255);
delay(500);
analogWrite(p, 0);
delay(500);
}
}
void pinWriteC (void)
{
for (auto &p : pin) {
ledcWrite(p, 255);
delay(500);
ledcWrite(p, 0);
delay(500);
}
}
void setup()
{
for (auto &p : pin) {
ledcAttach(p, 500, 8);
}
}
void loop()
{
//pinDigital();
//pinAnalog();
pinWriteC();
}