Issue with #include <Wire.h> Causing Code to Fail When Using DRV8825 and AccelStepper

I'm working on a project where I'm using the DRV8825 stepper motor driver with the AccelStepper library. I've got the Enable pin of the DRV8825 attached to a PCF8575 I2C multiplexer. I used the below code and it works perfectly, but not if I test with the multiplexer, and I've discovered that the stepper doesn't move even if I just include <PCF8575.h> (or even #include <Wire.h>) in the code. Any ideas how I can solve this?

#include "AccelStepper.h"
// #include <PCF8575.h>
// PCF8575 pcf8575(PCF8575_ADDR);

// Define stepper motor connections and motor interface type. Motor interface type must be set to 1 when using a driver:
#define dirPin 17
#define stepPin 21
#define motorInterfaceType 1

// Create a new instance of the AccelStepper class:
AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);

void setup() {
  Serial.begin(9600); 
  stepper.setMaxSpeed(1000);
}

void loop() {
  stepper.setSpeed(250);
  stepper.runSpeed();
}

Why?
Which Arduino? Post a wiring diagram.

Most likely a pin assignment conflict. Make a list of all the pin assignments in each code and library module, which in turn depends on which Arduino you have.

My bad, I'm using an Arduino nano, here's a schematic.

form_q

Do those assignments make sense for a Nano?

1 Like

From your schematic, shouldn't

be

#define dirPin 5
#define stepPin 9

?

The ENABLE pin must be pulled LOW for the motor to run, is the PCF8575 doing that?

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