Answers:
ESP8266内置有一个LED,该LED固定在D4上,如LoLin板上标记的那样,它映射到GPIO2。需要注意的一件事是,LED为低电平有效。换句话说...将PIN 2设为'0'将打开LED,将PIN 2设为'1'将关闭LED
这是LoLin板上唯一的LED,与其他在GPIO16上具有LED的开发套件不同。
我有nodeMCU v3,Pin 2为我工作。
#define LED_BUILTIN 2
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, LOW); // Turn the LED on (Note that LOW is the voltage level
// but actually the LED is on; this is because
// it is acive low on the ESP-01)
delay(1000); // Wait for a second
digitalWrite(LED_BUILTIN, HIGH); // Turn the LED off by making the voltage HIGH
delay(2000); // Wait for two seconds (to demonstrate the active low LED)
}