Measuring Switch State using PIC
This will work. When the switch is open, the pin does not float, it is pulled down via R2. A couple of caveats, however.


You need to ensure that the ground of the MCU is connected to the ground of the 12V supply.
The motor is an inductive load, and as such you will get voltage spikes when it is  switched off. To counteract this you should clamp the input to the MCU to its voltage rails (0V &amp; 5V for example) using diodes - one with the anode at the MCU input pin and the cathode at the positive MCU supply and one with the anode at ground and the cathode at the MCU pin.