Inerfacing switch & led with any controller
I am not a programmer but after reading your question on solution came in to my mind which I am going to explain below.

For the below logic your LED and Switch both should be controlled with a controller's different I/O pin. First controller should sense the switch pressed logic and based on the switch logic controller has to first sense the LED I/O Pin Logic for previous condition of LOW or HIGH Logic. If LED Pin logic is HIGH make it LOW and vice versa. Note LED's pin I/O has to be reversed only after the switch is pressed.

Below logic can be followed

Switched pressed (Y/N)
{

If Y
    {
      changed the logic of LED port pin // If HIGH, change it to LOW if LOW, change it to HIGH

        else N
              { Do nothing}
        }
}