|
大家好,新人學(xué)習(xí)arduino。遇到了一個(gè)奇怪 的問(wèn)題。
提示:expected initializer before numeric constant,數(shù)值常量之前應(yīng)為初始值設(shè)定項(xiàng)
按我理解第一步預(yù)定義常量不就是在設(shè)定初始值嗎?附上程序和報(bào)錯(cuò)信息。
請(qǐng)大佬指點(diǎn)一二。謝謝!
程序:
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);
}
}
}
報(bào)錯(cuò)信息
Arduino:1.8.5 (Windows 7), 開發(fā)板:"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
在文件 -> 首選項(xiàng)開啟
“編譯過(guò)程中顯示詳細(xì)輸出”選項(xiàng)
這份報(bào)告會(huì)包含更多信息。
|
|