I have several readings from some sensors. The goal is to print them one by one with a delay of 3 sec. It is fairly easy to do, but the problem is that there is a button and if i set those delays with delay() i have to catch up the time in a loop to press it. If i set it with delay() Arduino will wait for 3 sec between readings. That way button part in sketch will be accessible every 15 sec or so.

Is there a way to achieve it that Arduino go through, say five readings with a delay of 3 seconds, but still read button press?

I am not sure which way to approach to this problem. What logic to use.

  • 1
  • Yes i have read that post already. But not sure how to set it in my project. I need to print one reading, wait few seconds, print second etc. And while i print those readings i still can press that button and do other thing. – mrBarns Mar 5 '18 at 8:26
  • In every single tutorial there is example in millis() but for leds. I don't have few displays, only one. I need to print it on one, after few seconds, print another one, etc. A little bit confused in all of this. – mrBarns Mar 5 '18 at 8:28
  • turn on led or print to lcd. just commands. – Juraj Mar 5 '18 at 8:34
  • 1
    If you can't work out how to do it with millis() yourself (hint: start with BlinkWithoutDelay example and change what you want to do each time it triggers), you would probably benefit from using the SimpleTimer. – Majenko Mar 5 '18 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.