derek bernsen wrote:but with the other code it just keeps the LED lit at all times
With my code above, of course, if you don't reverse the HIGH/LOW on LED, it will be ON all the time, since the reverse wiring is done, but it will OFF momentarily at the connect. Simply reverse the HIGH/LOW on those digitalWrite().
Other then that, I don't see why it is not working, since it is working on my side, and the Serial output is also proving that.
The only pitfall I saw, as mentioned earlier is that sometime the disconnect is not efficient.