Illuminated LED and push-button using only 2 wires
simulate this circuit &ndash; Schematic created using CircuitLab

Figure 1. A simpler circuit using two GPIO pins.

How it works:


IO2 toggles between high and low.
IO1 toggles between input and output high.


Table 1.

State  Button  IO1       IO2     LED
  1    Open    Out high  Out lo  ON
  2    Open    Input     Out hi  Off   IO1 reads low due to pull-down R2.
  3    Pressed Out high  Out lo  Off   LED shorted out.
  4    Pressed Input     Out hi  Off   IO1 pulled high by IO2.



Light the LED when IO1 is high and IO2 is low.
Read the switch when IO2 is high and IO1 is input.