如何以不同的速率更新传感器值 [英] How to update sensor values at different rates

查看:23
本文介绍了如何以不同的速率更新传感器值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个从不同传感器读取数据的 arduino 项目.我取值并将它们存储在一个数组中.问题是我想以不同的速率更新传感器值.例如,我不想每 250 毫秒更新一次,而是每 50 毫秒更新一次.但我希望它能够在传感器更新之间运行循环.我能想到让它开始工作的唯一方法是延迟,但这会停止循环.

I'm working on an arduino project that reads in data from different sensors. I take the values and store them in an array. The problem is that I'd like to update the sensor values at different rates. For example, I wan't to update one every 250ms but another every 50ms. But I'd like it to the loop running in between sensor updates. The only way I can think of getting it to kind of work is with delays but that stops the loop.

推荐答案

您可以使用为要读取的每个传感器设置间隔的millis() 函数.看看 Arduino 网站上的无延迟闪烁示例

You can use the millis() function with intervals set for each of the sensors you want to read. Have a look at the Blink Without Delay example on the Arduino website

http://arduino.cc/en/Tutorial/BlinkWithoutDelay

这篇关于如何以不同的速率更新传感器值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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