Another possibility is to read the entire line with one call and then break it apart. If you are sending across the Serial port and terminating the data by pressing the Enter key and the data are "D123", it will look like "D123\n", where '\n' is the newline character caused by the Enter key. If that's the case:
char buffer[10];
char target:
int value;
int numberOfBytesRead;
// more of our code...
if (Serial.available()) {
numberOfBytesRead = Serial.readBytesUntil('\n', buffer, 10); //gets everything up to the Enter key
buffer[numberOfBytesRead] = '\0'; // make it a null terminated string
target = toupper(buffer[0]); // First letter
value = atoi(&buffer[1]); // The number
switch(target) {
case 'D': // Down
// whatever you want to do
break;
case 'U': // Up
// whatever you want to do
break;
case 'L': // Left
// whatever you want to do
break;
case 'R': // Right
// whatever you want to do
break;
default:
MyErrorCondition(); // Shouldn't be here...
break;
}
// Rest of your code
See if that works...