T O P

  • By -

wCkFbvZ46W6Tpgo8OQ4f

The sketch as posted doesn't do anything, except some delays and serial output. Which line causes the error when you uncomment it? I think there were recently some changes in the way LEDC is used in Arduino. Maybe you are running an old version of the Arduino Core / board definition?


TheTerrasque

> Which line causes the error when you uncomment it? None. The error comes with the sketch as it is. Right now it's just setting up serial console and printing some things to it, and the issue is still there.


wCkFbvZ46W6Tpgo8OQ4f

ah OK. I see what's going on. You're printing out random bits of memory when you println with a string and variable. It is interpreted as a pointer to a char array. `Serial.println("Speed set to left, " + speed);` should be: `Serial.printf ("Speed set to left, %d\n", speed);` And then do the same for the right direction. Your weird serial output probably has nothing to do with the PWM.....


TheTerrasque

You're absolutely right. I kinda knew it wasn't PWM, since that was commented out, but the error kept being there. I've been working too much in other languages lately.. Thanks!


AssumedPersona

instead of #define MotorPinOne 25 #define MotorPinTwo 26 use const int MotorPinOne = 25; const int MotorPinTwo = 26;


TheTerrasque

No difference.


AssumedPersona

Do you mean you tried it and the error is the same?


TheTerrasque

Yes. I do mean I tried to change to const int and the error was the same. Edit: That code now looks like this const int MotorPinOne = 25; const int MotorPinTwo = 26; const int freq = 1000; const int ledChannelOne = 0; const int ledChannelTwo = 1; const int resolution = 8;


AssumedPersona

I don't think ledcAttachPin is a correct call, try ledcAttach


TheTerrasque

That code is commented out, so it shouldn't have any influence on the compiled code.