IR Remote Stepper Motor

Hello everyone, I'm currently working with IR Remote, IR receiver, and stepper motor.

My project is to control the spin of the stepper motor when I press a button e.g., ( button 1 = clockwise and button 2 = counter-clockwise) and I want the spin to be continuous every time I press the button. The problem I am facing now is that using the switch case statement, whenever I press the first button it works but if I want to press the second button to do the counter-clockwise movement, it does not trigger. Anyone can help me with this?

#include <Stepper.h>
#include <IRremote.h>
const int RECV_PIN = 3;
IRrecv irrecv(RECV_PIN);
decode_results results;
const int stepsPerRevolution = 256;
Stepper myStepper(stepsPerRevolution, 6,8,7,9);




void setup(){
  myStepper.setSpeed(100);
  irrecv.enableIRIn();
  irrecv.blink13(true);
}


void loop(){
    if(irrecv.decode(&results)){
      switch(results.value){
        case 0xFF30CF:
        while(results.value == 0xFF30CF){
          myStepper.step(stepsPerRevolution);
          delay(1); 
        }
        
        case 0xFF18E7:
         while(results.value == 0xFF18E7){
          myStepper.step(-stepsPerRevolution);
          delay(1);
         }  
      }
       
      irrecv.resume();
    }
    
}

Once you're in this while loop, there's no way out
You need to resume/decode.

So i have to include this command at the bottom right?

irrecv.resume();

Personally, I'd drop the while loops, and allow the loop() function to do the thing it does best.

Yes, I've done this awhile ago, but the problem was the spin of the motor is not continuous since the stepper motor I'm using can only do 256 steps per rev if it is greater than that it overheats and does not spin.

overheating is not a problem of speed or number of steps.
It is a problem of a too high current.

With the current adjusted to the stepmotors specs you can drive the steppermotors 24 hours per day /7 days a week for a hundred years

So please post the details of your project.
Datasheets of your stepper-motor and the stepper-driver
Be the change you want to see in the world
best regards Stefan

if your code read the buttons directly, i would have said the code should drive the motor while the button is pressed. instead, your talking about buttons on some other device that repeatedly sends an IR code while the button is pressed

so whenever you receive a code you can drive the motor some number of steps

or you can capture a timestamp whenever you receive a code and drive the motor until some timeout-period after not receiving the code

Thanks to all who gave their feedback, I've finally solved the issue by adding these codes inside the while loop :smiley:

if(irrecv.decode(&results)){
            if(results.value != 0xFF30CF) break; 
          }
          irrecv.resume(); 

if(irrecv.decode(&results)){
            if(results.value != 0xFF18E7) break; 
          }
          irrecv.resume();

that doesn't look like the appropriate solution