【问题标题】:Code won't compile for WeMos D1 but works fine for Arduino Uno代码不会为 WeMos D1 编译,但适用于 Arduino Uno
【发布时间】:2017-04-11 13:31:22
【问题描述】:

代码无法为 WeMos D1 编译,但适用于 Arduino Uno。

我得到了错误

error: 'A1' was not declared in this scope
#include "HX711.h"

HX711 scale(A1, A0);// parameter "gain" is ommited; the default value 128 is used by the library

void setup() {
    Serial.begin(9600);//2280
    scale.set_scale(1810.f); //// this value is obtained by calibrating the scale with known weights
    scale.tare();
}

void loop() {
    Serial.print("\n");
    Serial.print(scale.get_units(), 1);
    scale.power_down(); // put the ADC in sleep mode
    delay(500);
    scale.power_up();
}

【问题讨论】:

  • ESP8266 只有一个模拟引脚,不能用作数字引脚。
  • 下面的答案将被标记为分辨率。

标签: arduino esp8266 arduino-esp8266


【解决方案1】:

来自reference doc of the ESP8266 Arduino repo

ESP8266 有一个可供用户使用的 ADC 通道。它可以用来 要么读取 ADC 引脚上的电压,要么读取模块电源电压 (VCC)。

要读取施加到 ADC 引脚的外部电压,请使用模拟读取(A0)。输入 电压范围为 0 — 1.0V。

所以 A1 也没有定义。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多