Xbee Delay

Hello, I am trying to send a variable resistor's input from one Arduino to another (wirelessly using Xbee modules). The second Arduino will vary the brightness of an LED depending on the value of the variable resistor.

Everything is working but there is about a 1 second delay before the LED responds to the change of the variable resistor.
Here is my code:

Sender:

// SENDER

int analogValue5, val5;

void setup()
{Serial.begin(9600);}

void loop()
{
analogValue5 = analogRead(5);
val5 = map(analogValue5, 0, 1023, 255, 0);

Serial.write(val5);

delay(300);
}

Receiver:

// RECIEVER

int incomingByte;

void setup() {

Serial.begin(9600);

pinMode (11, OUTPUT);


}

void loop() {
if (Serial.available()) {   

 incomingByte = Serial.read();
 delay(300);

}
analogWrite (11, incomingByte);
delay(10);

}

Anyone knows how I can reduce or eliminate this delay?

Anyone knows how I can reduce or eliminate this delay?

I think you mean delay(), not delay. It really should be obvious how to reduce the delay().

Remove all delay() functions from your code. If you need something to happen after some pause, look at Blink without delay example in arduino IDE.

Thanks, I thought you need to have some delay() for the Xbees to communicate.

Mate, could you put here such a stupid question? Uff

If you need fastest communication, set baud rate to 115200 and set RO register to 0 (packetization timeout).

Put analogWrite (11, incomingByte); into if.