arduino - 函数定义 1 错误,我尝试在我的 arduino ide 中自动格式化并按 ctrl+t,但问题仍然存在
问题描述
我不断收到这些 Buzzer-CLiCK:33:19: error: a function-definition is not allowed before '{' token void circling() { ^ Buzzer-CLiCK:40:17: error: a function-definition is not allowed在 '{' token 之前 void stopc () { ^ exit status 1 在 '{' token 之前不允许函数定义
下面是我的代码
const int BUTTON_PIN = 0; // Arduino pin connected to button's pin
const int BUZZER_PIN = 12; // Arduino pin connected to Buzzer's pin
const int LED_1 = 13;
int point;
int pin[] = {9, 8, 7, 6, 2, 3, 4, 5};
void setup() {
Serial.begin(9600);
for (int i = 0 ; i <= 7; i++) { // initialize serial
pinMode(pin[i], OUTPUT);
pinMode(BUTTON_PIN, INPUT_PULLUP); // set arduino pin to input pull-up mode
pinMode(BUZZER_PIN, OUTPUT); // set arduino pin to output mode
}
}
void loop() {
int buttonState = digitalRead(BUTTON_PIN); // read new state
if (buttonState == LOW) {
Serial.println("The button is being pressed");
digitalWrite(BUZZER_PIN, HIGH); // turn on
digitalWrite(LED_1, HIGH);
circling();
}
else if (buttonState == HIGH) {
Serial.println("The button is unpressed");
digitalWrite(BUZZER_PIN, LOW); // turn off
digitalWrite(LED_1, LOW);
stopc();
}
void circling() {
for (int i = 0; i <= 7 ; i++) {
digitalWrite(pin[i], HIGH);
digitalWrite(pin[i], LOW);
}
}
void stopc () {
for (int i = 0 ; i <= 7; i++) {
digitalWrite(pin[i], LOW);
}
}
}
解决方案
推荐阅读
- tsql - SQL WHERE 条件是一个字段的字符串可以在另一个字段中找到
- python-3.x - 如何在 or-tools 求解器中计算数组元素?
- prolog - 如何从 SWI-Prolog 中的 tuples_in/2 转换为 GNU Prolog 中的 fd_relation/2?
- javascript - Highstock 日期和时间错误
- python - “将存档附加到 EXE”时出现 PyInstaller FileNotFound 错误
- python - 在追加之前将字符串转换为列表
- c - mbstowcs() 在 Windows 中给出不正确的结果
- python - Flask 404 未找到图像
- android - 关于我的服务器和客户端 android 应用程序中的套接字的问题
- uml - 企业服务总线 - UML 图