【发布时间】:2020-06-27 19:10:36
【问题描述】:
为什么这段代码会导致 Arduino Mega2560 不断重置?
void setup() {
Serial.begin(9600);
Serial.println("SETUP");
delay(500); //without this line Serial prints "SESESESESE"
analogWrite(10, 100);
analogWrite(11, 50); //reboots after this line
}
void loop() {
Serial.println("LOOP"); //doesn't reach here
}
Arduino 串口输出如下:
SETUP
SETUP
SETUP
SETUP
SETUP
SETUP
SETUP
SETUP
注意事项:
1) 如果我将引脚 10 和 11 替换为其他引脚(例如 8 和 9),Arduino 不会重新启动,但它也会使用引脚 12 和 13 重新启动(我猜引脚 10-13 有点特殊)。
2) 如果我在对 analogWrite 的调用中使用相同的值(例如 100 和 100),Arduino 不会重新启动。
【问题讨论】:
-
显示连接到此的电路。
-
Arduino 没有插入任何东西,这很有趣。