want to receive two messages at receiver end that is one after another

I want to receive two messages at receiver end that is one after other. And want to blink led according to it. The code is compiling but it doesnot work according to it.What is the problem in code? Here is

Receiver code

 #include <VirtualWire.h> 
 byte message[VW_MAX_MESSAGE_LEN]; // a buffer to store the incoming messages 
 byte messageLength = VW_MAX_MESSAGE_LEN; // the size of the message 
 int LED =13;
 int pin=11;
 void setup() 
 { 
 Serial.begin(9600); 
 Serial.println("Device is ready"); 
 // Initialize the IO and ISR 
 vw_setup(2000); // Bits per sec 
 vw_rx_start(); // Start the receiver 
 pinMode(LED,OUTPUT);
 } 
 void loop() 
 { 
   char message[VW_MAX_MESSAGE_LEN + 1]; 
 if (vw_get_message(message, &messageLength)) // Non-blocking 
 { // Existing start of if body
   message[messageLength] = '\0';

   if(strcmp(message [0], "obstacle absent") == 0)
   {
      digitalWrite(LED,HIGH);
   }
    if(strcmp(message [0], "obstaclepresent") == 0)
    {
       digitalWrite(LED,LOW);
    }

    if(strcmp(message [1], "value is less") == 0)
   {
      digitalWrite(LED,HIGH);
   }
    if(strcmp(message [1], "value is more") == 0)
    {
       digitalWrite(LED,LOW);
    };
    
 { 
 Serial.print("Received: "); 
 for (int i = 0; i < messageLength; i++) 
 { 
 Serial.write(message[i]); 
 } 
 Serial.println("");
 
 delay(200); 
 } 
 }
}

transmitter code

#include <VirtualWire.h>

int ObstaclePin = 7;  // This is our input pin
int Obstacle = HIGH;  // HIGH MEANS NO OBSTACLE
const int AOUTpin=0;//the AOUT pin of the alcohol sensor goes into analog pin A0 of the arduino
const int DOUTpin=8;//the DOUT pin of the alcohol sensor goes into digital pin D8 of the arduino



int limit;
int value;

void setup()
{
  pinMode(ObstaclePin, INPUT);
  pinMode(DOUTpin, INPUT);
  Serial.begin(9600);
   // Initialize the IO and ISR
   vw_setup(2000); // Bits per sec

}
void loop()
{
  
  Obstacle = digitalRead(ObstaclePin);
    if (Obstacle == LOW)
  {
    Serial.println("obstacle absent");
    send("message [0]=obstacle absent");
  }
  else
  {
    Serial.println("obstacle present");
    send("message [0]=obstaclepresent ");
  }
  value= analogRead(AOUTpin);//reads the analaog value from the alcohol sensor's AOUT pin
limit= digitalRead(DOUTpin);//reads the digital value from the alcohol sensor's DOUT pin
Serial.print("Alcohol value: ");
Serial.println(value);//prints the alcohol value
Serial.print("Limit: ");
Serial.print(limit);//prints the limit reached as either LOW or HIGH (above or underneath)
delay(100);
if (limit == HIGH){
Serial.println("value is less");//if limit has been reached, LED turns on as status indicator
send("message [1]=value is less");
}
else{
Serial.println("value is more");//if threshold not reached, LED remains off
send("message [1]=value is more");
}

  delay(200);
}
void send (char *message)
{
    vw_send((uint8_t *)message, strlen(message));
    vw_wait_tx(); // Wait until the whole message has gone
}

message[0] is a char. It will never compare to "obstacle absent" or any of your other string literals.

The fact that you send a message in two different places on the sender has NOTHING to do with the fact that you receive messages in one place on the receiver.

You have EXACTLY one message to deal with at any given time. That message can contain "obstacle absent" OR "obstaclepresent" OR "value is less" OR "value is more".

You need to remove the [] from message[] to compare the messages. Then each side of the comparison is a string.
The second & third paragraphs of PaulS's reply aren't relevant to your question.

But why this in your receive loop?

delay(200);

Won't you miss some transmissions sometimes? Or is VirtualWire entirely interrupt-driven, and has an internal buffer that can store more than one message?

You need to remove the [] from message[] to compare the messages

but when I remove[] from message[], then there is an error in code.

Here is an error

virtualwire_r_ir:27: error: expected ')' before numeric constant

    if(strcmp(message 0, "obstacle absent") == 0)

                      

exit status 1
expected ')' before numeric constant

Not only the [], also the 0 :wink:

yes, sorry for it. But now the receiver doesn't receive any output. How do I send both of these messages at the receiver end and get the required output? I have stuck on this since two weeks .

How do I send both of these messages at the receiver end

You don't. You send the messages on the sender end.

Forget trying to consume the messages for now. Just print them.

What do you ACTUALLY receive?

Still the code compile but no output on serial monitor. I want to make you clear that I want to receive output of two sensors at receiver. One is of ir sensor i.e. for obstacle and other one is of breathalyser.
And for this I want to receive two variables as output.

How can I receive two variable as output at receiver and how can I delay second message after first one?

Still the code compile but no output on serial monitor.

The code you didn't post? No output from the sender? Or no output from the receiver?