board locks up

I'm trying to set a pin high or low from a serial message from my app and i am setting it's initial state at setup the board locks up when i do the following. if i set the alarm pin high then close the serial port and reopen it the board hangs

my realbasic app establishes a serial connection. if they change something in prefs i close the serial port and reopen it. before i added the alarm code this worked fine. now the board hangs when i close the serial port and reopen it.

any ideas?

Thanks Jeff

the new code in setup is

pinMode(alarmPin, OUTPUT); digitalWrite(alarmPin, LOW);

the new code in loop is all the serial stuff to do if incomingbyte is "A", "F" or "V"

void setup()
{
  Serial.begin(57600);

  pinMode(ledPin, OUTPUT);
  pinMode(2, INPUT);
  pinMode(alarmPin, OUTPUT); //pin 4
  digitalWrite(alarmPin, LOW);
  digitalWrite(2, HIGH); //anemometer input pin
  Serial.print(ver, DEC);  //display board firmware version #
  Serial.println("ver");  
  ledPinState = digitalRead(ledPin);
  count = 0;
  attachInterrupt(0, increment_counter, FALLING); 

}

void loop()
{
  delay(1000);

  digitalWrite(ledPin, !ledPinState); //blink led on board
  ledPinState = !ledPinState;

  if (Serial.available() > 0) // read the incoming byte
  {        
    incomingByte = Serial.read();
    if (incomingByte=='A') // turn alarm pin on
    {
      digitalWrite(alarmPin, HIGH); 
    }
    if (incomingByte=='F') // turn alarm pin off
    {
      digitalWrite(alarmPin, LOW);
    }
    if (incomingByte=='V') // get version
    {
      Serial.print(ver, DEC);  //display board firmware version #
      Serial.println("ver");  
    }

  }

}