arduino gsm door alarm

Thanks for the help. Am i getting confussed with HIGH and LOW. If the pin is HIGH then the pullup resistor pulls the pin from 0v to 5V and LOW pulls the the pin down to 0v
:blush:

digitalWrite(doorContactPin,LOW);
  val = digitalRead(doorContactPin);

The doorContactPin pin is defined as an input. Setting it HIGH or LOW turns on or off the pullup resistor. Turning the pullup resistor on an off in the code makes no sense. You either want it always on, or always off.

Code:
  val = digitalRead(doorContactPin);
  while(val == HIGH){
    val = digitalRead(doorContactPin);
  }

Some comments that describe why this code is here, in setup(), would be a good idea.

should this NOT be in setup()