Bluetooth arduino problem!

Hi

I will explain my problem with the BT arduino and i'll tell also how i resolved it.
The frirst 10 minutes everything seemed allright but when i compiled and uploaded the following code,
the bluetooth funcionality was broken, i mean that it was not possible to detect the blutooth hardware(arduino) either from the PC or from mobile phone. I see that it was possible to detect the bluetooth harware only when i reseted the board(arduino) and it lasts only some seconds as the chip starts to procede with the loop funcion.
So after hours spend over the internet for resolving the problem i had an idea that resolved my problem.
I reseted the bt arduino and in that moment i was searching from bluetooth software of PC for detecting that, as it was detected it asks you for the key, enter the default key "12345" before advancing in this procedure you need to reset the board in order that BT arduino drivers will be installed(if you fail repeat the process from the begining, you need to exertion those seconds the bluetooth could be recognized).
After this procede with arduino software to upload any working code you would like( i used led_blink example), becarefull here you need to set the COM port and if it does not appear restart the arduino software and imediately reset BT arduino in order that the port COM appears in TOOLS/Serial port, then you have to reset the board and imediately upload the code( repeat this last step for some times if you don't succede, you need to find the right intervall of time).
If you need more information i could be disposable.

The wrong code was:

int incomingByte = 0; // for incoming serial data
int ledPin = 13;
int count=0;

void setup() {
Serial.begin(115200); // opens serial port, sets data rate to 9600 bps
pinMode(ledPin, OUTPUT);
}

void loop() {
Serial.print(count);
// send data only when you receive data:
if (Serial.available() > 0) {
incomingByte = Serial.read();
if(incomingByte == 0)
digitalWrite(ledPin, LOW);
else if(incomingByte == 1)
digitalWrite(ledPin, HIGH);
}
}

Thank You