如何停止循环的Arduino [英] how to stop a loop arduino
本文介绍了如何停止循环的Arduino的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的循环,我将如何结束循环?
无效循环(){
//读取按钮输入引脚: 一个++;
Serial.println(一);
analogWrite(speakerOut,NULL); 如果(一个大于50&放大器;&放大器;一个与所述; 300){
analogWrite(speakerOut,200);
} 如果(A< = 49){
analogWrite(speakerOut,NULL);
} 如果(一个或GT; = 300&放大器;&放大器;一个与所述; = 2499){
analogWrite(speakerOut,NULL);
}
解决方案
Arduino的具体规定绝对没有办法退出的循环
功能,展出由code实际运行的:
设置();为(;;){
循环();
如果(serialEventRun)serialEventRun();
}
此外,在微控制器上有没有什么退出到摆在首位。
你能做的最接近的是刚刚暂停处理器。直到它的复位,将停止处理。
I have this loop, how would I end the loop?
void loop() {
// read the pushbutton input pin:
a ++;
Serial.println(a);
analogWrite(speakerOut, NULL);
if(a > 50 && a < 300){
analogWrite(speakerOut, 200);
}
if(a <= 49){
analogWrite(speakerOut, NULL);
}
if(a >= 300 && a <= 2499){
analogWrite(speakerOut, NULL);
}
解决方案
Arduino specifically provides absolutely no way to exit their loop
function, as exhibited by the code that actually runs it:
setup();
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
Besides, on a microcontroller there isn't anything to exit to in the first place.
The closest you can do is to just halt the processor. That will stop processing until it's reset.
这篇关于如何停止循环的Arduino的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文