Stepper command: stepper.setPinsInverted

Hey guys,

I have finished a long lasting project. It's an automatic fish feeder. After finishing it, I teared appart everything to put it together inside a case. That was not easy.
Now, I have a small problem. :slight_smile:
My stepper seems to move backwards if it should go forword. So maybe I plugged in the cables on the A4988 reverse by accident. It is very difficult to get them out now as you can see on the pictures.

So my idea is, to use the stepper.setPinsInverted command to do the job.
Does anyone know the roots of this command?
I still use the command in my code but I do not know the effects cause that part of the code was an example from somewhere else.
At the moment the command in my void setup() looks like this:

void setup() {
  Serial.begin(115200);
  servoMotor.attach(SERVO_PIN);  // attaches the servo on ESP32 pin
  lightInit = analogRead(sensorPin);
  Serial.println(lightInit);
  pinMode(onoffpin, OUTPUT);
  digitalWrite(onoffpin, LOW);
  pinMode(buttonPin, INPUT); //initialize the pushbutton pin as an input
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  digitalWrite(LED1, LOW); 
  digitalWrite(LED2, LOW); 
  digitalWrite(LED3, HIGH); 
  stepper.setPinsInverted(false, false, true);
  stepper.setEnablePin(25);
  pinMode(MS1, OUTPUT);
  pinMode(MS2, OUTPUT);
  pinMode(MS3, OUTPUT);
  digitalWrite(MS1, HIGH);
  digitalWrite(MS2, HIGH);
  digitalWrite(MS3, HIGH);

Maybe someone can help me. I want to avoid again tear appart the finished case. :confused:

The pictures are just to illustrate the whole project. :slight_smile:



i think this is unlikely since it runs.
more likely the pins aren't specified correctly and the configuration corrected. you don't show the pin configuration in the posted code

1 Like

Thank you very much.
I moved the 1A/1B to the 2A/2B cables and the other way around and now it is working.
But regardless, I am still interested in this stepper.setPinsInverted command and if it would be possible to do this job by changing something in the code.

Have you seen the AccelStepper reference for that function?

I know this reference but I did not test anything in it. I am also no native speaker in english so it is difficult for me to understand in details what the theory says. That was the reason I aske here. But obviously nobody else tried this stuff.

But it's ok, my project is done now and everything is fine.

THank you very much for your efforts to help me :slight_smile:
really nice.
Thanks.

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