problem in blinking an led as message recieved by reciever

I am facing this problem since two weeks. I have connected ir sensors at transmitter to know whether obstacle is present or absent. I send this message to receiver. I want to blink an led if message receiver at receiver end is “obstacle absent”. But led doesn’t work as I want. What is the problem in my code?

Here is my 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.println("Device is ready"); 
 // Initialize the IO and ISR 
 vw_setup(2000); // Bits per sec 
 vw_rx_start(); // Start the receiver 
 void loop() 
 if (vw_get_message(message, &messageLength)) // Non-blocking 
 Serial.print("Received: "); 
 for (int i = 0; i < messageLength; i++) 
 if(digitalRead(pin)=="Received: obstacle absent")
 if(digitalRead(pin)=="Received: obstaclepresent")
 if(digitalRead(pin)=="Received: obstacle absent")

The digitalRead() function returns HIGH or LOW. These are #defined names with value of 1 and 0 respectively.

Do you REALLY think that 1 will equal a string literal? That 0 will?

Yaa you are absolutely correct. So ,how the receiver read the input as obstacle absent or present. and How led will blink as message received?

So ,how the receiver read the input as obstacle absent or present.

Where does the input come from? The input from a digital pin will not be the string "Obstacle present" or the string "Obstacle absent". You print those when the radio receives them.

The radio library put the data in an array. You can make a string out of the data, and then use strcmp() to compare the array data.

char message[VW_MAX_MESSAGE_LEN + 1]; // a buffer to store the incoming messages

First, you need to provide room in the array for the NULL to make it an array. Second, you should change it's type to char.

Then, you need to lie to the function, and tell it that you are passing it an array of the right type:

 if (vw_get_message((byte *)message, &messageLength))

Next, you need to add a NULL to the array.

{ // Existing start of if body
   message[messageLength] = '\0';

   if(strcmp(message, "obstacle absent") == 0)
      // Nothing in the way...

I am newbie to Arduino,sorry to say, but I am not able to understand what you are trying to say. Can you please help me by code. What should be code for it.

Can you please help me by code. What should be code for it.

I showed you what changes you need to make. I can not reach your hand to hold it.

thanks for helping. I have done with it.