在Sparkfun ESP8266上写入串行监视器

时间:2018-07-26 18:34:15

标签: esp8266 arduino-ide arduino-esp8266

下面是我当前的代码:

#include <Wire.h>
  #include <ESP8266WiFi.h>
  #include <BlynkSimpleEsp8266.h>

  // You should get Auth Token in the Blynk App.
  // Go to the Project Settings (nut icon).
  char auth[] = "836addccd2ee4f05b96f0f3ad831249e"; // ***Type in your Blynk Token

  // Your WiFi credentials.
  // Set password to "" for open networks.
  char ssid[] = "_Fast&Furious";// ***your wifi name
  char pass[] = "Mclaren2018";// ***and password
  const int MOTION_PIN = 4; // Pin connected to motion detector
  WidgetLCD lcd(V1);
  void setup()
  {
    Serial.begin(115200);
    Blynk.begin(auth, ssid, pass);
    pinMode(MOTION_PIN, INPUT_PULLUP);
    Serial.println("SETUP");
  }

  void loop()
  {
    Blynk.run();
    int proximity = digitalRead(MOTION_PIN);
  if (proximity == LOW) // If the sensor's output goes low, motion is detected
  {
    Blynk.virtualWrite(5,1023);
    lcd.clear();
    lcd.print(0,0,"Motion detected");
    Serial.println("Motion detected!");
  }
  else
  {
    Blynk.virtualWrite(5,0);
    lcd.clear();
    lcd.print(0,0,"Motion NOT detected");
    Serial.println("Motion NOT detected!");
  }
  }

我目前正在尝试向串行控制台写一些文本。但是,当我上传代码时,它将只向控制台写入一个k字符串。产生如此奇怪的输出,我做错了什么?

这是我一直关注的教程的链接:http://designinformaticslab.github.io/productdesign_tutorial/2017/01/24/motion_sensor.html

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:2)

这一切对我来说都很不错,您确定串行监视器上的波特率设置正确吗?我会很快地写一个新程序,只做串行输出并使其正常工作(这简化了解决的问题,并且在串口速度之类的情况下更加明显),然后返回到更完整的程序,应该可以。