How should I connect this switch to my Arduino?

Hi guys, so I'm curious to how I should connect this switch to send a signal to my Arduino. I know with a normal 4pin button, I need a resistor but do I need one for my switch as well?

This is my code.

const int SWITCHpin = 12;
const int ledPin = 11;

int SWITCHpinState = 0;
int ledPinState = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(SWITCHpin, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  BTNpinState = digitalRead(BTNpin);

  if(SWITCHpinState == HIGH) {
    digitalWrite(solPin, HIGH);
  }else{
    digitalWrite(solPin, LOW);
  }

}

Your sketch won't compile. At least solPin is not defined.

On your switch, you connect COM to ground on the Arduino and you connect NO (normally open) to the desired pin (ideally through a 1k resistor). The resistor is only a protection incase a sketch is loaded in the Arduino which would make the pin an output and cause a short circuit.

You should use pinMode(SWITCHpin, INPUT_PULLUP); to implement the internal pullup resistor.

You have a label "250V" on the switch. Don't be tempted to connect this to 250 Volts if you are using it with an Arduino.

Depends how you want to read the switch.
NO means Normally Open (so it closes/completes/forms the circuit/counts as a button press when pushed down)
NC means Normally Closed (so it opens/disconnects/breaks a circuit when the switch is pushed down)

So if you want a standard operating button, you would just use the COM and the NO pins. Treat it like 2 pins of any other microswitch button you might've had experience with (the 4 pins you mention are just 2 sets of 2 pins). Ignore the NC pin.

So you don't NEED a resistor if you use internal pullup. So the part you say 'I know with a normal 4pin button, I need a resistor', I would check your knowledge, because it's not entirely correct.

6v6gt:
Your sketch won't compile. At least solPin is not defined.

On your switch, you connect COM to ground on the Arduino and you connect NO (normally open) to the desired pin (ideally through a 1k resistor). The resistor is only a protection incase a sketch is loaded in the Arduino which would make the pin an output and cause a short circuit.

You should use pinMode(SWITCHpin, INPUT_PULLUP); to implement the internal pullup resistor.

You have a label "250V" on the switch. Don't be tempted to connect this to 250 Volts if you are using it with an Arduino.

INTP:
Depends how you want to read the switch.
NO means Normally Open (so it closes/completes/forms the circuit/counts as a button press when pushed down)
NC means Normally Closed (so it opens/disconnects/breaks a circuit when the switch is pushed down)

So if you want a standard operating button, you would just use the COM and the NO pins. Treat it like 2 pins of any other microswitch button you might've had experience with (the 4 pins you mention are just 2 sets of 2 pins). Ignore the NC pin.

So you don't NEED a resistor if you use internal pullup. So the part you say 'I know with a normal 4pin button, I need a resistor', I would check your knowledge, because it's not entirely correct.

Thank you very much for your answers guys, I appreciate it! Didn't know about the INPUT_PULLUP, what does it do exactly? Maximum voltage going through the switch is going to be 4.5-5.4V.

What I've been taught is to use the two pin on the same side of the button, one of them connected to the positive wire the other one connected to the input pin of the Arduino nano while also having a resistor on the same button pin connected to the ground. To be honest, I have no idea why.

I would think that the input pin on the Arduino nano would act as an ground and therfore you would only need to make a connection to a positive wire?