我修改的脚本有问题。我收到“Ping_Library_Example:9: error: expected unqualified-id before 'if'”
我确定我在某处有一些小语法错误,有什么想法吗?顺便说一句,原始脚本有“void loop”而不是“if”。使用 when 时也可能会发生同样的错误,并且出现相同的错误。有任何想法吗?
#include <Ping.h>
Ping ping = Ping(13,74,29);
void setup(){
Serial.begin(115200);
}
if(digitalRead == HIGH){
ping.fire();
Serial.print("Microseconds: ");
Serial.print(ping.microseconds());
Serial.print(" | Inches ");
Serial.print(ping.inches());
Serial.print(" | Centimeters: ");
Serial.print(ping.centimeters());
Serial.println();
}