Ir module and servo motor with d1 r1 esp8266

Can anyone tell me the code for to connect ir and servo motor to esp8266 when the ir signal is high servo motor should rotate and stay for 5sec after that it should come back please its urgeny

(deleted)

Look at the code examples for servos and various sensor inputs. First get the IR device outputting a value, then use that value to trigger the servo to do what you want.