I bought this switch, I don't know the wiring, I think it's 5v and GND but I'm not sure.
https://www.amazon.co.uk/mxuteuk-Terminal-Position-Miniature-Dashboard/dp/B07SCSQP9F/ref=mp_s_a_1_3?crid=3KR8412WZCV7D&dib=eyJ2IjoiMSJ9.NSHSvYeoAZlkRsoVG_VNFiA-y59ykDAWWNqh4aExNGINVktvVFyRmqScQxDdfX59JDrZB7Kxt-iJU1G4RV0xVqxeFX35ms5scx-oOSQRDD2Dlom3jLKCsa5A4lpUJ49zONPd7wFCJPPH2EelN2dOw4ZPrKpNagpisWYG-m5FIA7A9T0-tTgIUVRKJJlh08PZhRPxTqPY7VNBFHoCCXH0Lw.v8vRpbvq7qdj2aOBMNWU7zZuSlXh_yqnmOhxnwJuM34&dib_tag=se&keywords=on+off+toggle+switch&qid=1710962215&sprefix=on+off+toggl%2Caps%2C100&sr=8-3
If you connect the switch to both 5V and GND and close the switch you will create a short circuit. Guaranteed to burn your power supply. Or your Arduino.
What do you want to do?
It's neither of those things. It's just two terminals that are either connected together or not, depending on the switch position.
The best way to connect it to an Arduino is to connect one terminal to the Arduino pin and the other to ground, and use pinMode(pin, INPUT_PULLUP).
The center pin is common. The bat handle points to the pin that is connected. If the switch is left is pointing to the right pin.
FYI
- let’s say we have circuit S1.
Let’s say the switch is 10 feet from the Arduino.
This means we are taking the +5v supply line out 10 feet and 10 feet back.
5v is now extended 20 feet with the potential of it coming in contact with things that can go pop if there was ever a short circuit on the cable.
Also, sending 5v out on a 20 foot wire allows inductive coupling to noise sources that can cause serious problems back at the Arduino. - If we are using S2, the R1 pull-up is back at the Arduino, the switch is 10 feet away as before.
If there was a short on the 10 feet of wire, the external pull-up (R1) limits the short circuit current.
So the centre pin is GND and I connect the offset pin to digital
That would work. When you assemble it be sure to align the pins the same or you will have on up on some and down on other.
Thank you
You are welcome, glad we could help.
Not sure we helped so much. @donut still clings to some misconceptions:
The centre pin is no different to the other pin, it is not special. They are just 2 pins. When the switch is in one position, the 2 pins are connected. In the other position they are not connected, as I said in post #3. I'm sorry if, together, we have confused you.
Look at the first picture that @LarryD posted in post #5. The image shows buttons but from a wiring perspective your switch is not different.

