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

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

问题描述

我工作的一个Arduino项目,来自不同传感器的数据读取。我取值,并将其存放在数组中。问题是,我想以不同的速度来更新传感器值。例如,我wan't更新一个250ms的每但是另外每隔50ms。但我想它想的传感器更新之间运行的循环。我能想到的它让来样工作的唯一方法是延迟但停止循环。

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.

推荐答案

您可以使用米利斯()为每个要读取传感器的设置的时间间隔功能。看看眨眼毫不拖延例如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天全站免登陆