Wemos D1无法运行代码

时间:2018-03-31 15:43:19

标签: arduino esp8266 arduino-esp8266

我买了这个主板enter image description here

enter image description here

据我所知,我正确安装了驱动程序和库(我可以在usb设备中看到该板并上传代码),但每次我尝试运行程序时,都会在串行监视器中得到这个结果enter image description here并且董事会没有点亮任何领导。我也尝试打印一个hello world,但我得到的结果相同。

我的配置是: enter image description here

一个例子是: enter image description here

我希望你能帮助我,谢谢你!

2 个答案:

答案 0 :(得分:0)

我认为LED不闪烁的问题是因为许多ESP12主板使用GPIO 2而不是GPIO 1作为内置LED。 有关详细信息,请参阅此issue

尝试将其添加到草图的开头:

#define LED_BUILTIN 2

或仅使用2代替LED_BUILTIN

将重新定义LED_BUILTIN以使用gpio 2而不是gpio 1

对于串口监视器,我暂时没有直接使用Arduino IDE,但是你还是没有在串口上打印任何内容。

这是草图的更新版本,应该使LED闪烁并将一些消息打印到显示器。 (在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)
}

答案 1 :(得分:0)

我的问题是一个错误的董事会。我向卖家索取了一个新的,并且我在问题中提供的代码工作得很好。