Using 12V limit switch as input

GND on Arduino must be connected to GND of the 12v supply.

Google resistor voltage divider to get 12v down to 5v (if this is a 5v Arduino).

A 6.8K (R1) and 4.7K (R2) divider should work for you.