pinMode(D1, OUTPUT);
digitalWrite(D1, LOW);
Here, I have used the D1 (GPIO-5) as OUTPUT, if you use another GPIO pin then replace it with that.
For the INPUT add
pinMode(D1, INPUT);
Some GPIOs have limitations, if you make them HIGH or LOW during the booting process, the BOOT will fail.
You can refer to the following picture for that.
![Image](https://easyelectronicsproject.com/wp-content/uploads/2020/05/NodeMCU-input-and-output-pins-1.jpg)
You can also refer to the following article
https://easyelectronicsproject.com/esp3 ... fi-manual/