How to Pause/Stop certain command

Hi! we are currently making a program for a IR remote controlled relay network. We are to set a button (case X) that when it is pressed, it will make other certain buttons (case A, B, C, etc.) unusable or paused, and return to normal when another button (case Y) is pressed.

We used switch-case command for with the IRremote library

EDIT:

Sorry for the Noobish post. was in a hurry earlier. I just wanted to ask what code/codes can I use to pause/stop certain case commands so that the desired functions are the only functions to operate, and return it to operating state once a button is pushed again.
Thanks!

oh, here is the whole code

#include <IRremote.h>

int IRpin = 11;  // pin for the IR sensor
int Relay1 = 5;    // Relay 1 pin
int Relay2 = 6;    // Relay 2 pin
int SystemSwitch = 9;   // Controls all the Relay
int SystemPause = 8;    // sets the command pause
IRrecv irrecv(IRpin);   
decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(Relay1, OUTPUT);
  pinMode(Relay2, OUTPUT);
  pinMode(SystemSwitch, OUTPUT);
  


  digitalWrite(Relay1, LOW);
  digitalWrite(Relay2, LOW);
  digitalWrite(SystemSwitch, LOW);
  digitalWrite(SystemPause, LOW);
}

void loop()
{  
 if (irrecv.decode(&results))
 {
    Execute();
    Serial.println(results.value);
    irrecv.resume();   // Receive the next value
  }

}
  


void Execute() {


  switch (results.value) {
    case 21225:       //(case X) supposed to make the other button push neglected
      delay(150);
      digitalWrite(SystemPause, HIGH); 
      delay(1000);
      break;
    case 13033:       //(case Y) supposed to return normal opperation after systempause
      delay(150);
      digitalWrite(SystemPause, LOW); 
      delay(1000);
      break;
    case 16:          //(case A)toggles the contact of Relay1
      delay(150);
      digitalWrite(Relay1, !digitalRead(Relay1));
      delay(1000);
      break;
    case 2064:          //(case B)toggles the contact of Relay2
      delay(150);
      digitalWrite(Relay2, !digitalRead(Relay2));
      delay(1000);
      break;
    case 2704:          //(case C)turns OFF all relays in the network
      delay(150);
      digitalWrite(Relay1,HIGH);
      digitalWrite(Relay2,HIGH);
      delay(1000);
      digitalWrite(SystemSwitch, !digitalRead(SystemSwitch));
      delay(150);
      break;
     case 3216:           //turns all relays in the network to open contact
      delay(150);
      digitalWrite(Relay1,HIGH);
      digitalWrite(Relay2,HIGH);
      break;
     case 1168:           //turns all relays in the network to closed contact
      delay(150);
      digitalWrite(Relay1,LOW);
      digitalWrite(Relay2,LOW);
      break;
    default:
      break;
  }
  delay(20);
}

ZephyrLS: Hi! we are currently making a program for a IR remote controlled relay network. We are to set a button (case X) that when it is pressed, it will make other certain buttons (case A, B, C, etc.) unusable or paused, and return to normal when another button (case Y) is pressed.

We used switch-case command for with the IRremote library

Please post your actual code, rather than screenshots. (It's hard to copy and paste code from a screenshot into the IDE for testing/verifying.)

And place it between [code]code tags[/code] when you do so, please. :)

Edit: Oh, and post all of it, so it will compile. If it's too large to post and the forum software complains, attach it.

ZephyrLS: Hi! we are currently making a program for a IR remote controlled relay network. We are to set a button (case X) that when it is pressed, it will make other certain buttons (case A, B, C, etc.) unusable or paused, and return to normal when another button (case Y) is pressed.

We used switch-case command for with the IRremote library

What problems are you having? Was there a question with this?

Delta_G: What problems are you having? Was there a question with this?

That's a good question. I didn't notice that no help was asked for, apart from a brief mention in the title.

@ZephyrLS, what exactly needs to be stopped/paused?

the toggles and switches of the relay contacts, tfrom Switch-case 16 up to the last, Switch-case 1168. I'd like to pause the other commands so when i push the button from the remote, it wont send the command to the relay, until the unpause button is pushed.

IR codes are the case ## btw.

Get rid of ALL the delay()s if you want a responsive program.

Have a look at how millis() is used to manage timing without blocking in several things at a time

And please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum

…R

Robin2: Get rid of ALL the delay()s if you want a responsive program.

I put those delay because one remote button push toggles the relay multiple times. it sends a stream of four codes with a short button push, which toggles the relay four times or so, so i put the delay(). Unless there are other commands for that.

I'd be looking up for that "millis()" thanks :)

ZephyrLS: Hi! we are currently making a program for a IR remote controlled relay network. We are to set a button (case X) that when it is pressed, it will make other certain buttons (case A, B, C, etc.) unusable or paused, and return to normal when another button (case Y) is pressed.

  • have a global (static) boolean variable named "paused"
  • X sets paused to true.
  • Y sets paused to false
  • A, B, and C check the current value of "paused", and do nothing if it is currently true.

can you please send a sample code? I’m just new to this functions and programming too.
I see how x and y can set the value true but I don’t know the *check the current value and do nothing" part.

ZephyrLS: but I don't know the *check the current value and do nothing" part.

if (paused == false) {
  // do something
}

...R