Stepper motor wont turn Counter clock wise

Hey guys!
I am programming a remote controlled stepper motor. When i press the up button on the remote, it goes clockwise. When i press the down button on the remote, its supposed to go counter clockwise but it keeps going clockwise. I have checked the wiring and there is nothing wrong. Any ideas?

Code:

#include <IRremote.h>

#include <Stepper.h>
#define STEPS 32

int stepsPerRevolution;
 Stepper myStepper(STEPS, 8,9,10,11);

 
int remotePin = 6;
IRrecv IR(remotePin);
decode_results cmd;

void setup() {
  Serial.begin(9600);
  IR.enableIRIn();
}

unsigned long lastCmd;
void loop() {

  if (IR.decode(&cmd)) {
    if (cmd.value != 0xFFFFFFFF)  {
      lastCmd = cmd.value;
    }
  switch(lastCmd ){

 
 case 0xFF629D:
            myStepper.setSpeed(500);
            stepsPerRevolution = 200;
            myStepper.step(70);
            break;



   case 0xFFA857:
            myStepper.setSpeed(500);
            stepsPerRevolution = -200;
            myStepper.step(70);
            break;
  }
 
  IR.resume();
  
  }
}

@hamsa123 , your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project

thank you.

'Is this the proper way to run backwards? What about:

            stepsPerRevolution = 200;
            myStepper.step(-70);

?

I would put both those lines in Setup()

Thank you! It started working now!

Great! I've never used that stepper library but sometimes "common sense" and some logic brings up ideas.

Thanks for the reply!

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