control 16 led´s on an Arduino Board

Hello dear Forum,
maybe someone can help me.
With a patch I want to be able to switch on and off a total of 16 LED´s on an Arduinoboard. I created the following sketch and patch. But it doesn't work and I don't understand what I'm doing wrong.
Can anyone help me?
Thank you very much!

int numled            = 16;
int ledpin[16]        = { 2,  3,  4,  5,  6,  7,  8,  9, 10,  11,  12,  13,  14,  15,  16,  17};
int ledon[16]         = {11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161};
int ledoff[16]        = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160};

int readvalue;
int i                 = 0;



void setup() {
Serial.begin(38400);
  for ( i = 0; i < numled; i++) {
  pinMode (ledpin[i], OUTPUT);
  }
}

void loop() {


    for ( i = 0; i < numled; i++) {
    if (Serial.available() > 0) {
    readvalue = Serial.read();
    if (ledon[i] == readvalue) {
      digitalWrite(ledpin[i], 1);
    }
    if (ledoff[i] == readvalue) {
      digitalWrite(ledpin[i], 0);
    }
   Serial.println(readvalue);  
   }
 }
}

serial_write.maxpat.zip (1.45 KB)

int ledon[16]         = {11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161};
int ledoff[16]        = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160};

I haven't a clue what these variables are for. A more descriptive name is clearly in order.

    for ( i = 0; i < numled; i++) {
    if (Serial.available() > 0) {

That's never going to work.

You need to read, and store, serial data until some end of packet market arrives, indicating that you can now parse and use the stored data.

sorry. i forgot to write that i want to control it with a max msp patch.
These variables are sent by the Max MSP patch.

These variables are sent by the Max MSP patch.

Values are sent, not variables. The patch MUST include some start and end of packet markers, so the Arduino can tell what constitutes a packet.