I recently bought a microswitch that has three pins common, normally open,
and normally closed. How would I connect them to a microcontroller.
Would I connect common to ground and the normally open or closed at my own descretion depending how I want it to work.
Normally you use pull-up resistors on a micro-controller, so common to ground (as you said) and the other two via seperate pull-up's to 5V, and also connected to two micro-controller inputs - so you can check either way.
However, this is rather a waste of two input pins, connecting just one will tell you the position of the switch - using either the normally open, or normally closed, is really up to you.
Some type of microcontroller cannot be left floating at their input. I would connect the common to the input, normally closed to ground and normally open to Vcc via a resistor.
Normally you use pull-up resistors on a micro-controller, so common to ground (as you said) and the other two via seperate pull-up's to 5V, and also connected to two micro-controller inputs - so you can check either way.
However, this is rather a waste of two input pins, connecting just one will tell you the position of the switch - using either the normally open, or normally closed, is really up to you.