How to read /debounce an illuminated switch using only two wires?
simulate this circuit &ndash; Schematic created using CircuitLab

Figure 1. Illuminated switch, opto-isolator and GPIO with internal pull-up enabled. Note separate ground symbols: the remote circuit can be completely isolated from the micro-controller for added noise immunity.

In button released position the opto-isolator will be on and the GPIO will be pulled low.

D2 will be infra-red type and will decrease the voltage to the LED by about 1.4 V and about 1.4 mA or so. It shouldn't be noticeable without a direct comparison.

Debounce can be done in software or by adding a capacitor between GPIO and ground. \$ C = \frac {\tau}{R} \$ where \$ \tau \$ is the desired debounce time and R is the internal pull-up value.