PHP + Arduino

Ahhh...

#include <LiquidCrystal.h>

const int ledPin = 9;
int serial;
int stop_bit = false;
int i = 0;
int array[0];
int result;
int check = false;

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

void setup() {
  Serial.begin(9600);
  lcd.begin(8, 2);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  if (Serial.available() > 0) {
    serial = Serial.read();
    if(serial == 4){
      stop_bit = true;
    } else {
      array[i] = serial;
      i++;
    }
  }
  if(stop_bit)
  {
    if(!check) {
      for (int x=0; x < i; x++){
         result += array[x];
      }
    check = true;
    }
    if(result == 'ON') {
      digitalWrite(ledPin, HIGH);
    } else if(result == 'OFF') {
      digitalWrite(ledPin, LOW);
    } else if (result != 0) {
       lcd.write(result);
       serial = 0;
    }
  }
}

Now when I write "dsa" I get only dddddddddddddddd on my lcd. :confused:

How I can calculate number of bits? That's only thing I neec.