[英]Wemos D1 not able to run code
我認為LED不閃爍的問題是因為許多ESP12板使用GPIO 2而不是GPIO 1作為內置LED。 有關更多詳細信息,請參見此問題 。
嘗試將其添加到草圖的開頭:
#define LED_BUILTIN 2
或僅使用2
代替LED_BUILTIN
這將重新定義LED_BUILTIN以使用gpio 2而不是gpio 1
至於串行監視器,我已經有一段時間沒有直接使用Arduino IDE了,但是無論如何您都不會在串行端口上打印任何內容。
這是草圖的更新版本,應該使指示燈閃爍並向顯示器顯示一些消息。 (在IDE中將串行端口的波特率設置為115200)
#define LED_BUILTIN 2
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
}
// the loop function runs over and over again forever
void loop() {
Serial.println("turning ON LED");
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
Serial.println("turning OFF LED");
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)
}
在我的情況下,問題是主板有故障。 我從賣家那里請求了一個新的,那個與我在問題中提供的代碼配合得很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.