void setup() {
Serial.begin(9600);
for (int i = 0; i < 6; i++) {
analogWrite(pin[i], 0);
}
Serial.print("");
}
You have not declared the pins to be output pins.
9600 baud is 1/12 the maximum rate that the Arduino can reliably process data. You may not get the throughput needed unless you pick up the pace.
while (Serial.available() > 0) {
delay(1);
input = Serial.read();
There is at least one character available, so wait a while to read it. I thought you said that speed was a goal. Is it, or not?
else if (input >= '0' && input <= '9') {
input = input - '0';
val[counter] = input;
counter++;
}
Sending string data that needs to be converted back to a number is also not in keeping with speed.
if (Serial.available() == 0 && counter > 0) {
How do you know that the data in val[] represents a complete packet?
delay (2);
Is speed an issue, or not?