Hello everyone. I am going to make a counter that will increase by 1 every millisecond until the button is pressed. But this counter is be slow aprx. 3000-4000 milliseconds in 10 seconds compared to real time. What should I do? I share the codes below. Thank you
And it does not matter much as no human can read a number changing every ms on a LCD anyway...
So update the LCD less frequently - may be every 50ms whilst keeping an actual start time so that you can display the real value at the end. (and don't use delay, use millis())
Please correct your post above and add code tags around your code, not quote tags: [code]`` [color=blue]// your code is here[/color] ``[/code].
It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)
need some time to execute too. So the complete time to execute your loop is more than one millisecond.
As you are a newbee I recommend reading this tutorial:
It is very easy to understand. It has the right mixture between writing about fundamental things and going ahead to get you going. You have the choice:
trying to write code with very little knowledge encountering all kinds of problems: compiler-errors, code behaves different than you expected etc which will make you spending time scratching yor head
or spending time reading an easy to understand tutorial to gain knowledge that will enable to write code that (most of the time) works
It is completely OK to ask questions here in the forum. Whenever you have posted a question. In the meantime waiting for an answer you could go on reading some lines in this tutorial instead of just waiting or scratching your head about your own code.