Couple of potential problems.
Firstly, if this a simple reed switch then you need to have it arranged with a pull up or pull down resistor to give you a valid signal. Not sure if this is the case from your description.
Secondly, in your code you never actually reads the switch. Your code needs to look like this:
#include <Serial.h>
int sensorPin = 12;
void setup(){
Serial.begin(9600);
pinMode(sensorPin, INPUT);
}
void loop() {
int magnetSensor = digitalRead(sensorPin);
if(magnetSensor == HIGH){
Serial.println("Close!");
}
if(magnetSensor == LOW){
Serial.println("Far...");
delay(200);
}
}
And you can simplify the two if statements to an if..else.