Controlling an Array of Motors
A switch state can be measured with a pullup resistor and a GPIO input. 

For example: 







simulate this circuit &ndash; Schematic created using CircuitLab

In some cases there may be an internal pullup that you can turn on and even get rid of R1 but it's better to run a bit more current through the switch than internal pullups deliver. R2 provides a bit of protection, and is not strictly necessary. Vdd will be 5V or 3.3V depending on the microcontroller. 

If the switch is connected to the motor internally (hard to tell from the photo) you'll likely have to disconnect it or you could damage the microcontroller.