在Arduino上运行程序时连续运行循环? [英] Continuously run loop while running program on Arduino?

查看:62
本文介绍了在Arduino上运行程序时连续运行循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于在 Arduino 中运行循环的问题.我已经对 Arduino 进行了编程,使它的 LED 慢慢淡出,我想添加一个在程序运行时闪烁的 LED.我可以更改整个程序并使 LED 在所有行之间闪烁,但我想知道是否有办法单独完成?是否可以在 void setup() 下运行一个循环,或者运行一个循环,然后继续运行第一个循环,然后继续运行下一个循环?

I have a question about running loops in Arduino. I've programmed an Arduino so that it slowly fades in LEDs and I'd like to add an LED that blinks while the program is running. I could change the whole program and put the LED blinking between all the lines, but I was wondering if there was a way it could be done seperately? Would it be possible to run a loop under void setup(), or to run a loop, and then move on to the next loop, while continuing to run the first loop?

闪烁的灯当然不是很重要,但我只是好奇它是否可以完成.

The blinking light is of course not really important, but I was just curious if it could be done.

推荐答案

我建议为此使用 msTimer2 库.

I suggest to use the msTimer2 library for this purpose.

http://playground.arduino.cc/Main/MsTimer2

在德国 Arduino 论坛最近的讨论中也可以找到其使用示例:

An example of its use can also be found in a recent discussion in the German Arduino Forum here:

http://arduino/.index.php?PHPSESSID=cf3a483ed1812def070ebeaae09691c3&topic=146086.msg1100336#msg1100336

您不需要懂德语.只需获取代码并尝试一下.

You do not need to understand German. Just take the code and try it.

这篇关于在Arduino上运行程序时连续运行循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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