0

Im trying to control 4 stepper motors with the AccelStepper library.

Something like this:

AccelStepper FL(1,stepPin,dirPin);
AccelStepper FR(1,stepPin2,dirPin2);
AccelStepper BL(1,stepPin3,dirPin3);
//AccelStepper BR(1,stepPin4,dirPin4);

The problem is, It works just fine if I declare 3 instance of the AccelStepper, but once I uncomment the 4th one there's an error.

Error message: Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "ESP32 Dev Module, Disabled, Default, 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"




In file included from C:\Users\Parit\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1/tools/sdk/include/esp32/xtensa/xtruntime.h:30:0,

                 from C:\Users\Parit\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1/tools/sdk/include/freertos/freertos/portmacro.h:80,

                 from C:\Users\Parit\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1/tools/sdk/include/freertos/freertos/portable.h:94,

                 from C:\Users\Parit\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1/tools/sdk/include/freertos/freertos/FreeRTOS.h:105,

                 from C:\Users\Parit\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\cores\esp32/Arduino.h:32,

                 from sketch\Test_file.ino.cpp:1:

C:\Users\Parit\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1/tools/sdk/include/esp32/xtensa/config/specreg.h:40:13: error: expected unqualified-id before numeric constant

 #define BR  4

             ^

C:\Users\Parit\Desktop\Test_file\Test_file.ino:31:14: note: in expansion of macro 'BR'

 AccelStepper BR(1,stepPin4,dirPin4);

              ^

Multiple libraries were found for "WiFi.h"

 Used: C:\Users\Parit\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.1\libraries\WiFi

 Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.42.0_x86__mdqgnx93n4wtt\libraries\WiFi

exit status 1

Error compiling for board ESP32 Dev Module.



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Im not sure if the problem is the ESP 32 or the code. I use the A4988 driver to connect with all 4 stepper motors.

3
  • Please show the complete error message – chrisl Oct 26 '20 at 15:31
  • Not in the comments please. You can add this information to your question by editing it – chrisl Oct 26 '20 at 15:52
  • ok sorry, i'll add it now –  QiQi Oct 26 '20 at 15:53
1

The variable name BR is already used somewhere else.

Use a different variable name

AccelStepper FL(1,stepPin,dirPin);
AccelStepper FR(1,stepPin2,dirPin2);
AccelStepper BL(1,stepPin3,dirPin3);
AccelStepper BackRight(1,stepPin4,dirPin4);
5
  • Thank you ! It's working now. But it's weird, I can confirm that I haven't used a variable with that name any where in my code/ –  QiQi Oct 26 '20 at 16:00
  • It's explained in the error message. It says BR is defined as a constant with value 4 (` #define BR 4`) – Gerben Oct 26 '20 at 16:07
  • Alright, but still, I didn't write "#define BR 4" In my code. Anyways, it's working now so it doesn't matter, Thanks. –  QiQi Oct 26 '20 at 16:11
  • The first definition necessarily in your code - it may be in one of the libraries your code included. – JRobert Oct 26 '20 at 17:49
  • According to the error message it's inside the file specreg.h. Try reading the error messages you get. They contain a lot more information than you'd think. They can be a bit overwhelming at first, but after a few of them you'll get a feel for what's relevant, and what to look for. – Gerben Oct 26 '20 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.