HC12 reading multiple pins

Hey all i am going to try and simplify what I am sure is a complicated question in which there are most likely numerous answers. I am building a wireless firework controller. The plan is to use 2 arduinos connected via hc12 modules. When a button is pressed at the transmitter it will send a pre programmed message to the receiver. I have the receiver set up that when it receives the message it will turn 1 of 6 pins(that will control a relay) high depending on which message is received. I plan on the button press being set up as a hardware interrupt. This is because when no buttons are pressed I want the transmitter to be continuely reading the state of several other pins hooked up to the receiver and reporting back there state. I envison it working like this;

transmitter sends message 1 to receiver
receiver receives message 1 and checks state of pin 1.
If Pin 1 is high, response message is sent back to the transmitter
transmitter receives response and turns LED 1 on

transmitter sends message 2 to receiver
receiver receives message 2 and checks state of pin 1.
If Pin 1 is high, response message is sent back to the transmitter
transmitter receives response and turns LED 2 on

and so on through the remaining pins

I was going to stager each message by using the millis timer so the transmitter would have time to receive a response and react.

My question is am i on the right track with this method of reading the receiver pins or is there a better way to do it? If its not could someone please provide a better way. i dont necessarily need specific code, just a-point in the right direction. Thanks!

am i on the right track with this method of reading the receiver pins or is there a better way to do it?

Why not read all of the pins and send them back as bits in a single byte ? From what you have said it sounds like using an interrupt is not needed either and that simple polling could do what you want

that is an intresting idea, i am not sure I know how todo that but I am sure I can figure it out. Thanks

@OP

I am trying to understand the meanings of the textual description of your original post with the help of the following 2-UNO + 2-HC12 setup. Please, adjust the current meanings/codes by return post.
hc12-3y1.png

Figure-1:

1. You have a button K1 connected at DPin-2 of UNO-S (UNO Sender) to interrupt the MCU over INT0 logic.

2. When you interrupt the UNO-S by K1, the MCU will jump at ISR and can send only one message (Say, Msg1). It can not send any other message; because, there are no further data to implement if-else/switch-case structure.

3. As you want to send various messages (say, Msg1, Msg2, ..., Msg5), let us (as per advice of Post#1) configure 5 DPins as inputs (3, 4, 5, 6, 7); read their curent logic values (open/close) and send them to UNO-R (UNO Receiver).

4. The UNO-R will receive all 5-bit data in 'ONE GO' and then will ignite the LEDs connected at the respective DPins of its IO lines.

5. Example Codes
Send the values of these DPins: 3, 4, 5, 6, 7 of UNO-S to UNO-R at 1-sec interval. The UNO-R will ignite LED3 connected at its DPin-3 if logic value of the received DPin-3 is found HIGH.

UNO-S Codes: (untested)

#include<SoftwareSerial.h>
SoftwareSrial SUART(10, 11);

void setup()
{
    Serial.begin(9600);   //SM1 is enabled
    SURT.begin(9600);    //software serial port is enabled
    for(int i = 3; i<8; i++)
    {
       pinMode(i, INPUT_PULLUP);   //3 - 7 are inputs with internal pull-ups
    }
}

void loop()
{
   SUART.write(PIND);    //sending the values of port pins of Port-D
   delay(1000);
}

UNO-R Codes: (untested)

#include<SoftwareSerial.h>
SoftwareSrial SUART(10, 11);

void setup()
{
    Serial.begin(9600);   //SM1 is enabled
    SURT.begin(9600);    //software serial port is enabled
    for(int i = 3; i<8; i++)
    {
       pinMode(i, OUTPUT);   //3 - 7 are outputs
    }
}

void loop()
{
   
    byte n = SUART.available();
    if (n !=0)
    {
       byte x = SUART.read();
       //----check x3 (bit3 of x foe HIGH and ignite LED3)---------- 
    }
}

hc12-3y1.png

GolamMostafa:
2. When you interrupt the UNO-S by K1, the MCU will jump at ISR and can send only one message (Say, Msg1). It can not send any other message; because, there are no further data to implement if-else/switch-case structure.

Considering the HC12 communicates over Serial, well, more likely a SoftwareSerial instance as you keep the Serial for communication with the PC, you can't send messages from within the ISR to begin with as SoftwareSerial needs interrups, and those are disabled while the ISR runs. All you can do is set a flag for loop() to check for. You can just as well poll that button in loop() and react to it that way.

There's absolutely no need for using an interrupt here, as usual when it comes to reading buttons interrupts only make it more complex (especially when you consider dealing with the inevitable button bounce!).

By the way, why should the receiver read back its pins and send that info back to transmitter? Whatever information that contains it should not come as a surprise as it's simply what transmitter told receiver to do in the first place.

The receiver will will be checking if there is continuity. Direct Arduino voltage is not strong enough to actually fire the ignitor(thus why the "fire" pin will be connected to a relay).