如何停止循环 arduino [英] how to stop a loop arduino

查看:472
本文介绍了如何停止循环 arduino的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个循环,我该如何结束循环?

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 特别提供了绝对无法退出其 loop 函数的方法,正如实际运行它的代码所示:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆