【发布时间】:2015-10-07 07:48:31
【问题描述】:
我编写了一个简单的 arduino 草图,使用用于读取引脚 0 的模拟读取(0)函数从引脚读取值。
验证代码时,我收到错误消息 - 'analogread' 未在此范围内声明。
我在某处读到analogRead 已被HAL 取代,但如果不再支持analogRead,我无法找到应该替换analogRead 的地方。
任何帮助/建议都会非常感谢。
我的草图中没有包含库,也许这就是原因,但我可以找到一个需要任何库的#include 的示例。
我的草图中的代码如下:
int fsrPin = 0; // the FSR and 10K pulldown are connected to a0
int fsrReading; // the analog reading from the FSR resistor divider
void setup(void) {
// We'll send debugging information via the Serial monitor
Serial.begin(9600);
}
void loop(void) {
fsrReading = analogRead(0);
Serial.print("Analog reading = ");
Serial.print(fsrReading); // the raw analog reading
// We'll have a few threshholds, qualitatively determined
if (fsrReading < 10) {
Serial.println(" - No pressure");
} else if (fsrReading < 200) {
Serial.println(" - Light touch");
} else if (fsrReading < 500) {
Serial.println(" - Light squeeze");
} else if (fsrReading < 800) {
Serial.println(" - Medium squeeze");
} else {
Serial.println(" - Big squeeze");
}
delay(1000);
}
【问题讨论】:
标签: c++ arduino arduino-uno arduino-ide