How to code an arduino to execute a particular code using a slide switch
Your switch wiring for D12 is wrong. You connect your inputs directly to ground and that can never change, regardless of the position of the switch. 

You effectively have:







simulate this circuit &ndash; Schematic created using CircuitLab

However you are over complicating things.  A SPDT switch is nothing more than two buttons, only one of which can be pressed at one time.  If one is pressed the other must be released. 

You can completely ignore half the switch and treat the other half as a button: if the "button" is pressed then the switch is in one position. If the "button" is released then it's in the other position. 

Unless it's a "center off" switch, in which case it has 3 positions, not 2, and the middle one has nothing connected.

If it is a simple 2-position SPDT switch then just disconnect the D12 wire and remove the right-and resistor in your drawing. Then read D13 to determine the position: HIGH is one position and LOW is the other.

If it's a 3-position "center off" switch then move the D12 wire 4 holes to the left so that it connects to the switch-resistor junction, not ground. Then you will need to read both D12 and D13 - which ever one is HIGH is the one that is activated, and the switch is in that position.

Then it's a simple "if / else" (2 position) or "if / elseif / else" (3 position center-off) structure to decide which code to run.