大家好,新人学习arduino。遇到了一个奇怪 的问题。
提示:expected initializer before numeric constant,数值常量之前应为初始值设定项
按我理解第一步预定义常量不就是在设定初始值吗?附上程序和报错信息。
请大佬指点一二。谢谢!
程序:
const int BUTTON_A 7
const int BUTTON_B 8
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN,OUTPUT);
pinMode(7,INPUT);
pinMode(8,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (LOW == digitalRead(BUTTON_A){
bool FLAG_A = 1;
unsigned long time_A_init = millis();
}
if (FLAG_A){
if (millis()-time_A_init > SET_A){
digitalWrite(LED_BUILTIN,HIGH);
FLAG_A = 0;
time_A_init = 0;
delay(1000);
digitalWrite(LED_BUILTIN,LOW);
}
}
}
报错信息
Arduino:1.8.5 (Windows 7), 开发板:"Arduino/Genuino Uno"
20200708_DELAY:2: error: expected initializer before numeric constant
const int BUTTON_A 7
^
D:\Alan wu\Arduino\20200708_DELAY\20200708_DELAY.ino: In function 'void loop()':
20200708_DELAY:16: error: 'BUTTON_A' was not declared in this scope
if (LOW == digitalRead(BUTTON_A){
^
20200708_DELAY:16: error: expected ')' before '{' token
if (LOW == digitalRead(BUTTON_A){
^
20200708_DELAY:29: error: expected primary-expression before '}' token
}
^
exit status 1
expected initializer before numeric constant
在文件 -> 首选项开启
“编译过程中显示详细输出”选项
这份报告会包含更多信息。
|