Try this:
int state = 0;
int led;
int ledState;
void loop() {
while (Serial.available())
{
if (state == 0)
{
led = Serial.read() - '0';
if(led >= 0 && led <= 7)
{
state = 1;
continue;
}
}
if (state == 1)
{
ledState = Serial.read() - '0';
if(ledState == 0)
{
shiftWrite(led,LOW);
}
else if(ledState == 1)
{
shiftWrite(led,HIGH);
}
state = 0;
}
}
}
You need what we call a state machine, here I use state=0 for the state corresponding to choosing LED number, state=1 is for the state that waits for the operation ON/OFF.