Skip to main content
Arduino

Return to Answer

added 83 characters in body
Source Link

Unless millis()-timeold is exactly 30000 milliseconds, you direct to fail. The value of revolutions, your previous successful parameter for use, is not so precise AND you have used a >= filter rather than the equality one (==). Thus you didn’t direct so readily to fail. And you don’t get to right the ship with new assignment of ‘timeold.’

Another observation is that you have already sampled for millis()-timeold once; there is no reason to sample it again a few lines later and it may well be a small - but different - result.

Solution: compute millis()-timeold once, perhaps store it as an unsigned long, and compare on a >= basis rather than a == basis. You can avoid being tardy in getting the conditional satisfied, and you can obtain highly frequent report out of wind speeds. Lastly, I would initialize, in setup(), timeold = millis() and not equal to zero.

Unless millis()-timeold is exactly 30000 milliseconds, you direct to fail. The value of revolutions, your previous successful parameter for use, is not so precise AND you have used a >= filter rather than the equality one (==). Thus you didn’t direct so readily to fail. And you don’t get to right the ship with new assignment of ‘timeold.’

Another observation is that you have already sampled for millis()-timeold once; there is no reason to sample it again a few lines later and it may well be a small - but different - result.

Solution: compute millis()-timeold once, perhaps store it as an unsigned long, and compare on a >= basis rather than a == basis. You can avoid being tardy in getting the conditional satisfied, and you can obtain highly frequent report out of wind speeds.

Unless millis()-timeold is exactly 30000 milliseconds, you direct to fail. The value of revolutions, your previous successful parameter for use, is not so precise AND you have used a >= filter rather than the equality one (==). Thus you didn’t direct so readily to fail. And you don’t get to right the ship with new assignment of ‘timeold.’

Another observation is that you have already sampled for millis()-timeold once; there is no reason to sample it again a few lines later and it may well be a small - but different - result.

Solution: compute millis()-timeold once, perhaps store it as an unsigned long, and compare on a >= basis rather than a == basis. You can avoid being tardy in getting the conditional satisfied, and you can obtain highly frequent report out of wind speeds. Lastly, I would initialize, in setup(), timeold = millis() and not equal to zero.

Source Link

Unless millis()-timeold is exactly 30000 milliseconds, you direct to fail. The value of revolutions, your previous successful parameter for use, is not so precise AND you have used a >= filter rather than the equality one (==). Thus you didn’t direct so readily to fail. And you don’t get to right the ship with new assignment of ‘timeold.’

Another observation is that you have already sampled for millis()-timeold once; there is no reason to sample it again a few lines later and it may well be a small - but different - result.

Solution: compute millis()-timeold once, perhaps store it as an unsigned long, and compare on a >= basis rather than a == basis. You can avoid being tardy in getting the conditional satisfied, and you can obtain highly frequent report out of wind speeds.

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /