I am trying to drive two stepper motors with the AccelStepper/MultiStepper library. I think I did get it to work before, but it's not working now. I have included my code below the error messages.

Is there something wrong with the code I have written or is there something within the library that I need to change?

    C:\Users\Shreeya\AppData\Local\Temp\ccTKlUO9.ltrans0.ltrans.o: In function `AccelStepper::enableOutputs()':
    C:\Users\Shreeya\Documents\Arduino\libraries\AccelStepper\src/AccelStepper.cpp:560: undefined reference to `pinMode'
    C:\Users\Shreeya\Documents\Arduino\libraries\AccelStepper\src/AccelStepper.cpp:561: undefined reference to `pinMode'
    C:\Users\Shreeya\Documents\Arduino\libraries\AccelStepper\src/AccelStepper.cpp:564: undefined reference to `pinMode'
    C:\Users\Shreeya\Documents\Arduino\libraries\AccelStepper\src/AccelStepper.cpp:569: undefined reference to `pinMode'
    C:\Users\Shreeya\Documents\Arduino\libraries\AccelStepper\src/AccelStepper.cpp:574: undefined reference to `pinMode'
    C:\Users\Shreeya\Documents\Arduino\libraries\AccelStepper\src/AccelStepper.cpp:575: undefined reference to `digitalWrite'
    C:\Users\Shreeya\AppData\Local\Temp\ccTKlUO9.ltrans0.ltrans.o: In function `AccelStepper::disableOutputs()':
    C:\Users\Shreeya\Documents\Arduino\libraries\AccelStepper\src/AccelStepper.cpp:550: undefined reference to `pinMode'
    C:\Users\Shreeya\Documents\Arduino\libraries\AccelStepper\src/AccelStepper.cpp:551: undefined reference to `digitalWrite'
    C:\Users\Shreeya\AppData\Local\Temp\ccTKlUO9.ltrans0.ltrans.o: In function `AccelStepper::setOutputPins(unsigned char)':
    C:\Users\Shreeya\Documents\Arduino\libraries\AccelStepper\src/AccelStepper.cpp:366: undefined reference to `digitalWrite'
    c:/program files/windowsapps/arduinollc.arduinoide_1.8.42.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/7.3.0/../../../../avr/lib/avr5/crtatmega328p.o:(.init9+0x0): undefined reference to `main'
    collect2.exe: error: ld returned 1 exit status
    Using library AccelStepper at version 1.61 in folder: C:\Users\Shreeya\Documents\Arduino\libraries\AccelStepper 
    exit status 1
    Error compiling for board Arduino Uno.

Main code:

#include <AccelStepper.h>
#include <MultiStepper.h>

// Define pin connections
const int dirPin1 = 2;
const int stepPin1 = 3;
const int dirPin2 = 4;
const int stepPin2 = 5;

// Define motor interface type
#define motorInterfaceType 1

// Creates an instance
AccelStepper stepper1(motorInterfaceType, stepPin1, dirPin1);
AccelStepper stepper2(motorInterfaceType, stepPin2, dirPin2);

MultiStepper steppers;

void setup() {
  // Configure each stepper
  // Then give them to MultiStepper to manage

void loop() {
  long positions[2]; // Array of desired stepper positions

  positions[0] = 1000;
  positions[1] = 500;
  steppers.runSpeedToPosition(); // Blocks until all are in position

  // Move to a different coordinate
  positions[0] = -1000;
  positions[1] = 1000;
  steppers.runSpeedToPosition(); // Blocks until all are in position
  • Does this problem persist if you close the IDE (all instances) and reopen it? – timemage Mar 10 at 23:58

Your Answer

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

Browse other questions tagged or ask your own question.