Can't seem to get if statements to work.

This is my send code:

/*  
 *   11/20/2019  This works.
 *               Receives data from Tx and prints it to 16x2 LCD.

*/

#include <SoftwareSerial.h>
#include "ringbuffer.h"

/*
 * 6 -----TX
 * 5 -----RX
 * 2 -----AUX  PULL Input
 * 3 -----EN   output
 * 4 -----MO   output
 * 
 */
 typedef enum
 {
   MODEL_INIT,
   MODEL_RX,
   MODEL_TX,
 
   MODE_WAIT,
 }MODEL_STATE;

 MODEL_STATE state = MODEL_INIT;
 /*
  引脚定义
 */
 #define GPIO_TX          6
 #define GPIO_RX          5
 #define GPIO_AUX         2
 #define GPIO_EN          3
 #define GPIO_MO          4
 #define GPIO_RST         7
 
 #define RB_MAX_LEN               512
 #define MODEL_MAX_BUFFER_SIZE    200
 
 #define SET_NORMAL_MODE()        digitalWrite(GPIO_EN, LOW);digitalWrite(GPIO_MO, LOW);Serial.print("Normal mode\r\n")
 #define SET_WAKE_MODE()          digitalWrite(GPIO_EN, LOW);digitalWrite(GPIO_MO, HIGH);Serial.print("Wake mode\r\n")
 #define SET_HALF_SLEEP_MODE()    digitalWrite(GPIO_EN, HIGH);digitalWrite(GPIO_MO, LOW);Serial.print("Half Sleep mode\r\n")
 #define SET_DEEP_SLEEP_MODE()    digitalWrite(GPIO_EN, HIGH);digitalWrite(GPIO_MO, HIGH);Serial.print("Deep Sleep mode\r\n")

uint8_t rx_data[255]; 
rb_t pRb;                                               ///< Ring buffer structure variable
uint8_t rbBuf[RB_MAX_LEN];                              ///< Ring buffer data cache buffer

SoftwareSerial mySerial(GPIO_RX, GPIO_TX);  // Define pin GPIO2 as RX and pin GPIO3 as TX. 

 // constants won't change. They're used here to set pin numbers:


// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h >
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);

int  open8 = 8; // door open, pin 8    ***********************
int  closed9 = 9; // door closed, pin 9    *******************



void setup() {

  lcd.begin (20, 4);
  lcd.setBacklightPin(3, POSITIVE);
  lcd.setBacklight(HIGH);
  
  pRb.rbCapacity = RB_MAX_LEN;
  pRb.rbBuff = rbBuf;
  rbCreate(&pRb);
  mySerial.begin(9600);         //Set Baud rate with DRF1268DS/DRF1262DS
   while(mySerial.read()>= 0){}    //clear serial buffer 
  // put your setup code here, to run once:
  Serial.begin(9600);           //Set Baud rate with PC
  Serial.println("sketch_jan25a_2020_lora_LCD_Tx_Garage");
  delay(1500);
  while(Serial.read()>= 0){}    //clear serial buffer  
  
  noInterrupts();                      //Disable interrupt
  pinMode(GPIO_AUX, INPUT_PULLUP);     //Set GPIO pin as input to connect AUX pin
  
  pinMode(GPIO_RST, OUTPUT);
  pinMode(GPIO_EN,  OUTPUT);            //Set GPIO as output to connect EN pin
  pinMode(GPIO_MO,  OUTPUT);            //Set GPIO as output to connect MO pin
  SET_NORMAL_MODE();                      // Set power mode
  interrupts();  //enable interrupt
  digitalWrite(GPIO_RST, LOW);         // Reset module DRF1268DS/DRF1262DS
  delay(10);
  digitalWrite(GPIO_RST, HIGH);
  delay(10);
//  Serial.print("systerm init ok...\r\n");  

  pinMode(open8, INPUT);  // door open switch.     Both inputs tied to grd through*************
  pinMode(closed9, INPUT); // door closed switch.  10K resistors. *************************


  
}

void loop() {


      int t;
  {                                                                                                     // **********************
  if ((digitalRead(open8) == HIGH) && (digitalRead(closed9) == LOW)) // door open all the way. Red LED.
  { t = 111;
   // Serial.println("111");
    //Serial.println("DOOR OPEN");
  }
  if ((digitalRead(open8) == LOW) && (digitalRead(closed9) == HIGH)) // door closed all the way. Green LED.
  { t = 222;
    //Serial.println("222");
   // Serial.println("DOOR CLOSED");
  }
  if ((digitalRead(open8) == LOW) && (digitalRead(closed9) == LOW)) // door between closed and open. Blue LED.
  { t = 333;
    //Serial.println("333");
    //Serial.println("DOOR IN BETWEEN");
  }

  else if ((digitalRead(open8) == HIGH) && (digitalRead(closed9) == HIGH)) // ERROR
  { t =999 ;
    //Serial.println("999");
   // Serial.println("DOOR ERROR");
  } 
                                                                                                 // ************************
  }

 
// const int a = ("BLUE 8_8 Tx ");
mySerial.println(t); //  sends to module to be transmitted
delay(2000);

   if(Serial.available()>0)     //Read data from PC COM port
   {
            uint8_t len = Serial.readBytes(rx_data,MODEL_MAX_BUFFER_SIZE);
                       
            rbWrite(&pRb,rx_data, len);  //Write data into the buffer of the Arduino board
           
            

   }
   
       if(mySerial.available()>0) //Read data from module DRF1268DS/DRF1262DS
   {
            uint8_t len = mySerial.readBytes(rx_data,MODEL_MAX_BUFFER_SIZE);          
            Serial.write(rx_data,len);    //Output data to the COM port of PC
            lcd.setCursor(2,0);
            lcd.write(rx_data,len);
            lcd.setCursor(14,0);
            lcd.write(" ");
            lcd.setCursor(15,0);
            lcd.write(" ");
            lcd.setCursor(3,1);
            lcd.write("GARAGE");
           // lcd.setCursor(0, 2);
           // lcd.write("                 ");
            delay(3000);
            lcd.clear();
            
            }
   switch(state)
   {
    case MODEL_INIT: 
         if(digitalRead(GPIO_AUX) == HIGH)
         {
 //          Serial.print("module init is ok\r\n");
           state = MODEL_RX;
         }
         break;
        
    case MODEL_RX: 
            if(digitalRead(GPIO_AUX) == HIGH) //Check if the module DRF1268DS/DRF1262DS is in idle status or not
            {
              uint16_t len = rbCanRead(&pRb);                               //Get the data length in the buffer of Arduino board
              if(len > 0)
              {
                  if(len > MODEL_MAX_BUFFER_SIZE)
                  {
                    rbRead(&pRb,rx_data,MODEL_MAX_BUFFER_SIZE);                  //Check if the data length in the buffer exceeds 200 bytes  
                    mySerial.write(rx_data,MODEL_MAX_BUFFER_SIZE);
                  }else
                  {
                     rbRead(&pRb,rx_data,len);                                    //Read out the data in the buffer and transfer it to the module DRF1268DS/DRF1262DS 
                     mySerial.write(rx_data,len);

                     
                  }
                  state = MODEL_TX; 
              }
            }
           
        break;
    
    case MODEL_TX:  
           if(digitalRead(GPIO_AUX) == HIGH)
         {
           state = MODEL_RX;
         } 
          break;
    default: break;
   }
   

  }

This is my receive code:

/*  
 *   
 *               Receives data from Tx and prints it to 16x2 LCD.

*/

#include <SoftwareSerial.h>
#include "ringbuffer.h"

/*
 * 6 -----TX
 * 5 -----RX
 * 2 -----AUX  PULL Input
 * 3 -----EN   output
 * 4 -----MO   output
 * 
 */
 typedef enum
 {
   MODEL_INIT,
   MODEL_RX,
   MODEL_TX,
 
   MODE_WAIT,
 }MODEL_STATE;

 MODEL_STATE state = MODEL_INIT;
 /*
  引脚定义
 */
 #define GPIO_TX          6
 #define GPIO_RX          5
 #define GPIO_AUX         2
 #define GPIO_EN          3
 #define GPIO_MO          4
 #define GPIO_RST         7
 
 #define RB_MAX_LEN               512
 #define MODEL_MAX_BUFFER_SIZE    200
 
 #define SET_NORMAL_MODE()        digitalWrite(GPIO_EN, LOW);digitalWrite(GPIO_MO, LOW);Serial.print("Normal mode\r\n")
 #define SET_WAKE_MODE()          digitalWrite(GPIO_EN, LOW);digitalWrite(GPIO_MO, HIGH);Serial.print("Wake mode\r\n")
 #define SET_HALF_SLEEP_MODE()    digitalWrite(GPIO_EN, HIGH);digitalWrite(GPIO_MO, LOW);Serial.print("Half Sleep mode\r\n")
 #define SET_DEEP_SLEEP_MODE()    digitalWrite(GPIO_EN, HIGH);digitalWrite(GPIO_MO, HIGH);Serial.print("Deep Sleep mode\r\n")

uint8_t rx_data[255]; 
rb_t pRb;                                               
uint8_t rbBuf[RB_MAX_LEN];                             

SoftwareSerial mySerial(GPIO_RX, GPIO_TX);  
 


// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h >
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);

int  open8 = 8; // door open, pin 8    ***********************
int  closed9 = 9; // door closed, pin 9    *******************



void setup() {

  lcd.begin (20, 4);
  lcd.setBacklightPin(3, POSITIVE);
  lcd.setBacklight(HIGH);
  
  pRb.rbCapacity = RB_MAX_LEN;
  pRb.rbBuff = rbBuf;
  rbCreate(&pRb);
  mySerial.begin(9600);         //Set Baud rate with DRF1268DS/DRF1262DS
   while(mySerial.read()>= 0){}    //clear serial buffer 
  // put your setup code here, to run once:
  Serial.begin(9600);           //Set Baud rate with PC
  Serial.println("sketch_jan25a_2020_lora_LCD_Rx_GarageB");
  delay(1500);
  while(Serial.read()>= 0){}    //clear serial buffer  
  
  noInterrupts();                      //Disable interrupt
  pinMode(GPIO_AUX, INPUT_PULLUP);     
  
  pinMode(GPIO_RST, OUTPUT);
  pinMode(GPIO_EN,  OUTPUT);            
  pinMode(GPIO_MO,  OUTPUT);            //Set GPIO as output to connect MO pin
  SET_NORMAL_MODE();                      // Set power mode
  interrupts();  //enable interrupt
  digitalWrite(GPIO_RST, LOW);         // Reset module DRF1268DS/DRF1262DS
  delay(10);
  digitalWrite(GPIO_RST, HIGH);
  delay(10);
//  Serial.print("systerm init ok...\r\n");  

  pinMode(open8, INPUT);  // door open switch.     Both inputs tied to grd through*************
  pinMode(closed9, INPUT); // door closed switch.  10K resistors. *************************


  
}

void loop() {

 


   if(Serial.available()>0)     //Read data from PC COM port
   {
            uint8_t len = Serial.readBytes(rx_data,MODEL_MAX_BUFFER_SIZE);
                       
            rbWrite(&pRb,rx_data, len);  //Write data into the buffer of the Arduino board
            
            
            

   }
   
       if(mySerial.available()>0) //Read data from module DRF1268DS/DRF1262DS
   {
            uint8_t len = mySerial.readBytes(rx_data,MODEL_MAX_BUFFER_SIZE);          
           // Serial.write(rx_data,len);    //Output data to the COM port of PC
          
            
            lcd.clear();
            lcd.setCursor(7,0);
            lcd.write(rx_data,len);
            lcd.setCursor(10,0);
            lcd.write("              ");
            lcd.setCursor(6,3);
            lcd.write("GARAGE");
            delay(2000);
            lcd.clear();
             
            }
   switch(state)
    {
    case MODEL_INIT: 
         if(digitalRead(GPIO_AUX) == HIGH)
         {
 //          Serial.print("module init is ok\r\n");
           state = MODEL_RX;
         }
         break;
        
    case MODEL_RX: 
            if(digitalRead(GPIO_AUX) == HIGH) 
            {
              uint16_t len = rbCanRead(&pRb);                               
              if(len > 0)
              {
                  if(len > MODEL_MAX_BUFFER_SIZE)
                  {
                    rbRead(&pRb,rx_data,MODEL_MAX_BUFFER_SIZE);                 
                     mySerial.write(rx_data,MODEL_MAX_BUFFER_SIZE);
                  }else
                  {
                     rbRead(&pRb,rx_data,len);                                      
                     mySerial.write(rx_data,len);

                     
                  }
                  state = MODEL_TX; 
              }
            }
           
        break;
    
    case MODEL_TX:  
           if(digitalRead(GPIO_AUX) == HIGH)
         {
           state = MODEL_RX;
         } 
          break;
    default: break;
   }
   

  }

What problems are you having ?

This is what I had to do to get both my programs and question on here.

When I send the number 111 it is received at the Rx and displayed as 111 on the LCD.

The problem is if I insert "if" statements into the Rx program to cause a serial print or make a LED light
then nothing happens.

I have tried : if ((rx_date, len == 111)) { }
And: if ((rx_data == 111)) { }
And if ((len == 111)) { }
No matter where I put the "if" statements or what I put inside the brackets nothing happens.
I'm thinking it has something to do with the type of data in the len.
I have been working on this for four days now and getting nowhere so decided to try here..

Why is rx_data an array of 255 bytes ?

To UKHeliBob:

I haven't the slightest clue. Both the Tx and Rx programs came as examples from the DORJI website for the DRF1262DS LoRa radio. I added the "if" statements to the Rx to show the states of my garage door and to transmit them to the Rx for display. 111` is door open, 222 is door closed, and 333 is door between open and closed. I then wanted to show 111 as a red LED, 222 as a green LED, and 333 as a blue LED. 111,222,333 are displayed on the LCD with no problems.

I had this same setup using a 433MHz Tx/Rx ( but different sketches ) and it worked with no problems except range.

The problem is if I insert "if" statements into the Rx program to cause a serial print or make a LED light then nothing happens.

I have tried : if ((rx_date, len == 111)) { }
And: if ((rx_data == 111)) { }
And if ((len == 111)) { }

mySerial.println(t); //  sends to module to be transmitted

You send your t value(111,222,333,999) as ascii characters with a new line terminator

You can take advantage of that on the receive side.

Where you have this in your RX code

if(mySerial.available()>0) //Read data from module DRF1268DS/DRF1262DS
   {
     uint8_t len = mySerial.readBytes(rx_data,MODEL_MAX_BUFFER_SIZE);

Change to

if(mySerial.available()>0) //Read data from module DRF1268DS/DRF1262DS
   {
     uint8_t len = mySerial.readBytesUntil('\n', rx_data, MODEL_MAX_BUFFER_SIZE); 
     rx_data[len] = '\0'; //null terminate message

You will now have a null terminated array (c-string) in rx_data.

Use strcmp to compare two c-strings.
http://www.cplusplus.com/reference/cstring/strcmp/

if(strcmp("111",rx_data) == 0){} //strcmp returns 0 if the two strings match

Thank you very much cattledog.

Not only did you solve my problem but I also learned something new.
I had no idea about comparing two c-strings and then using it in an "if" statement.
After about four days of beating my head against the wall this really made my day.

My Tx and Rx sketches now work exactly as I wanted them to.

Thanks again.