ESP8266 HARDWARE GUIDE

GPIO and onboard LED

Secure, capability-aware firmware architecture for HomeAutoPro devices.

Board mapping

On common NodeMCU ESP8266 boards, D4 maps to GPIO2 and the onboard LED is active-low. LOW turns it on. External drivers may use different polarity.

pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, power ? LOW : HIGH);
    uint16_t duty = 1023 - map(brightness, 0, 100, 0, 1023);