LinkNode D1 Serial stops working when using pinMode
Move int greenLedPin = D1; and int redLedPin = D3; to another pin, because D1 and D3 is Tx and Rx.



http://esp8266.github.io/Arduino/versions/2.0.0/doc/reference.html