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();
}
}