Create an array to store the data in, and an index into that array:
char inData[10];
byte index = 0;
Then, replace the if test with a while loop:
void loop()
{
while(Serial.available() > 0)
{
char aChar = Serial.read();
inData[index] = aChar;
index++;
inData[index = '\0';
}
// Do something with inData, like call atoi...
}
There are two issues with this code. One is that it does no error checking, like making sure there is room in the array before storing the new value in the array.
The other is that there is no way to tell which bytes in the serial buffer form a packet.
If you send "12" and "68" and there is a delay in reading the serial data, the buffer will contain "1268". Where does one value end and the next one begin?
If there is any delay in receiving the serial data, after you send "12", the Arduino may read the 1 before the 2 arrives, and assume it got a complete packet.
It's better to include start-of-packet and end of packet markers, like "<12><68>". This way, it is easy to see what constitutes a packet.