Hi,
I'm trying to implement a data logger, and I want to have a certain refresh rate for my sensors. I'm trying to use modulus division for my the delay (shown below):
// Delay for dataLogging
do
{
dt = millis();
}
while(dt%logInt);
Where logInt is my logging interval in milliseconds (set to 50, for 20Hz). The issue is when I try to log my data I get results every second, for the first 20 ms. IE, the results start printing at the start of every second, and print from 1000 to 1019 continuously (IE 1000, 1001, 1002 ... 1019)
Any advice? Is there another way to implement a delay for the sensors, or any other suggestions?
Link to full code: https://gist.github.com/1048063
Link to longer output sample: https://gist.github.com/1048067
Thanks a ton!
JR