issue Simple Timer program

I am also starting to learn arduino, today is day one.

Ran into this same problem.

Problem Statement:

  • When i load and test the sketch while connected via USB to a laptop, all worked fine.
  • but when testing the same setup on power supply the delay at the end of loop was not held.

Solution:

  • Do not write delay statement at the end statement of a loop, I think the arduino is optimized to ignore delay calls if there is no subsequent code (i.e. if the delay is the last line of your code)
  • To resolve this issue move the "same delay statement" to the top of the loop (first line) this will work.

Happy Sketching!

@mr_rathore, you have posted a new question in a very old Thread so I have suggested to the Moderator to move you to your own Thread.

You have not posted the program that you refer to and your description of the issue does not make sense. In general a delay() will be effective no matter where it is placed in the loop() function. If it needs to go at the start of your loop() function that is because of some of the other code that you have not shown us.

...R

@mr_rathore

TOPIC SPLIT
DO NOT HIJACK / NECRO POST !

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.