Here's the photo from the OP's post:
And, here's a way to do it:
Connect "To Switch" probably to the terminal without the red wire. But, if that doesn't work, then try the one with the red wire connected to it. Either way, it shouldn't damage anything. If neither connection works, then the switch is not on the "high Side", and the other side of the switch is either not being pulled up to 12V, or the pull up "resistor" [since I can't be sure what is really going on] is of a value that is not allowing a high enough voltage to appear at D2, thus not being interpreted as a HIGH by the Arduino. In which case, some measurements will need to be made [ask].
Then, you need to find a "Ground" on that circuit board. Not sure how to advise you, there.
The two diodes are not mandatory, but I put them there to make this as fool proof as possible. They help to protect the input from over and under voltage conditions.
I showed this connected to D2, but you can use any of the D inputs. Pins D2 and D3 are "External Interrupt" inputs. Using the External Interrupt feature means the Arduino will respond to a change in the switch, without having to do what is called "Polling" (i.e. checking over and over, in a loop, hoping to catch the event when it happens). BUT, for something like this, polling will likely work just fine, since it's a "slow event", and you probably don't need to know when it happens within microseconds of the event
The Sketch for this, will look something like this [UNTESTED!]:
Polling:
const byte ledPin = LED_BUILTIN; // To use the onboard LED to indicate the state of the Switch
const byte switchSensePin = 2; // If using pin D2 for sensing the Switch state
byte state = LOW;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(switchSensePin, INPUT); //Redundant, since this is the default state
}
void loop() {
state = digitalRead(switchSensePin);
digitalWrite(ledPin, state);
}
Interrupt:
const byte ledPin = LED_BUILTIN; // To use the onboard LED to indicate the state of the Switch
const byte switchSensePin = 2; // If using pin D2 for sensing the Switch state
volatile byte state = LOW;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(switchSensePin, INPUT); //Redundant, since this is the default state
attachInterrupt(digitalPinToInterrupt(switchSensePin), blink, CHANGE); // Calls the blink() function whenever a CHANGE is detected
}
void loop() {
// Do other non-interrupt stuff here [if there ever is any]
}
// This called whenever an interrupt occurs on pin D2
void blink() {
state = digitalRead(switchSensePin);
digitalWrite(ledPin, state);
}