Here is the working LED circuit that is turned on with the magnetic switch
Here is the code:
const int LED = 3;
const int sensor = 4;
int state;
// 0 close - 1 open wwitch
void setup() { 
    pinMode(sensor, INPUT_PULLUP);
}
void loop() { 
    state = digitalRead(sensor);
    if (state == HIGH){ digitalWrite(LED, LOW); } 
    else{ digitalWrite(LED, HIGH); } 
}