IR Receiver

Hi!
I got a Robot and but I also want to controll him through a TV controller and a IR Receiver on the Robot. I already got a good programm which allows me to drive forwards,backwards leftwards.... But it doesn´t work. Is it the TV controller?
Programm:
int E1 = 6;//M1 Speed Control
int E2 = 5;//M2 Speed Control
int M1 = 8;//M1 Direction Control
int M2 = 7;//M2 Direction Control
void setup(void) {
int i;
for(i=5;i<=8;i++)
pinMode(i,OUTPUT);
Serial.begin(9600);
}

void loop(void)
{
while (Serial.available() < 1) {}
char val = Serial.read();
int leftspeed = 255;
int rightspeed = 250;
switch(val)
{
case 'w':
forward (leftspeed,rightspeed);
break;
case 's':
reverse (leftspeed, rightspeed);
break;
case 'a':
left (leftspeed, rightspeed);
break;
case 'd':
right (leftspeed, rightspeed);
break;
default:
stop();
break;
}
}
void stop(void)
{
digitalWrite(E1,LOW);
digitalWrite(E2,LOW);
}
void forward(char a, char b){
analogWrite (E1,a);
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}
void reverse (char a,char b){
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2, LOW);
}
void left(char a,char b){
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}
void right (char a,char b){
analogWrite (E1,a);
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}

Please help me, what could be wrong?

while (Serial.available() < 1) {}

The above is blocking, therefore you will not be able to use IR.

.

And what should I use instead of this command?

Did you write this code?
Is this home work?

You have to make your code in loop() non blocking.
Only process serial data when it arrives, currently you sit and wait for data to arrive.

There are libraries for IR remote control data receiving.
Research here:
https://arduino-info.wikispaces.com/IR-RemoteControl

.

This programm was a suggestion. thank you!