IR remote button controls more than one action

Hey programmers!
I am programming a remote controlled stepper motor that when i hold the remote button, it keeps moving. I know that when you hold down a button on the remote, it gives off the hex FFFFFFFF. I want to be able to hold down the button so that it can move forward when i press the up button, and backward when i hold down the down button. Sadly i can only make the hex FFFFFFFF have one value. Can anyone help me?

code:


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


void loop() {
  if (IR.decode(&cmd)) {

  switch(cmd.value){
 
 case 0xFF629D:
            myStepper.setSpeed(500);
            stepsPerRevolution = 2048;
            myStepper.step(70);
            break;

  case 0xFFFFFFFF:
            myStepper.setSpeed(500);
            stepsPerRevolution = 2048;
            myStepper.step(70);
            break;

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

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

Thanks for replying! Can you please explain to me what this code does? and where do i put it in the code?

It repeats the last code sent, if it sees a 0xFFFFFFFFF, which is quite obvious I think.

Thank you! it finally works!

You just had to remember the last command received and reissue it, if the repeat is seen.

Alright. Thanks again! The only trouble i had understanding your code was the unsigned long part. I do not know what that means.

It's a variable big enough to hold the value received,
a normal int would be too small (on standard Arduinos).

Ohhh ok. I get it now. Thank you for your help and cooperation!

@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.

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