arduino gsm door alarm

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

You are getting confused about what digitalRead() and digitalWrite() are for, and when to use each one. The digitalWrite() function, for an INPUT pin, turns the pullup resistor on or off. The way that the switch is connected defines whether the pullup resistor should be on or off. The resistor should be turned on or off ONCE.

For an OUTPUT pin, the digitalWrite() function turns the pin on or off.

The digitalRead() function is for reading from an INPUT pin. It returns HIGH or LOW.

Look at the direction of the pin defined in doorContactPin. It is defined as an INPUT pin. That means that you would call digitalWrite() on that pin exactly once (or less) in the sketch. Not a bazillion times like you are doing now.

You WOULD call digitalRead() on that pin a lot; any time you want to know whether the door is open or closed, call digitalRead().

should this NOT be in setup()

As near as I can tell, in the absence of any comments, the place for that code is the bit bucket/round file/recycle bin (or whatever other euphemism for trash can that you like).