Have trouble with if statement

Hello,

We are trying to use an RF transmitter and a receiver to let a LED light flashing when the ultrasonic sensor detects an object that is close in a certain distance. Without placing the light, the receiver can successfully receive signals that detected by the sensor through the transmitter. Right now, we put the if loop code behind the receiver code and we are currently having issues with the loop to trigger the light. When the loop for the light is placed in the code it seems to conflict with the previous loops. Thank you.

Here are my code for if loop:

int sonarPin = 0; //pin connected to analog out on maxsonar sensor
int ledPin = 9;
int inchesAway;

void setup() {pinMode(ledPin, OUTPUT);

}

void loop() {
inchesAway = analogRead(sonarPin) /2;

if (inchesAway < 12) { // if something is 24 inches away then make a 1khz sound
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(250);
}
}

And code for receiver :

int ledPin = 9;
int tranin = 11;

oid setup()
{
// Initialize ASK Object
rf_driver.init();
// Setup Serial Monitor
Serial.begin(9600);
}

void loop()
{
// Set buffer to size of expected message
uint8_t buf[11];
uint8_t buflen = sizeof(buf);
// Check if received packet is correct size
if (rf_driver.recv(buf, &buflen))
{

// Message received with valid checksum
Serial.print("Message Received: ");
Serial.println((char*)buf);
}
}

oid setup()

Fix this first:

void setup()