Arduino Tutorial Part 6: Introduction to Millis Command | Arduino Timer Inside

preview_player
Показать описание
let's go to our today's topic, that is Millis command of Arduino. This is very interesting. It is equivalent to a free clock running for you. You just get an integer value from the command and utilize it wherever required, this will enhance your programming skill.

Let's see the program code line by line. This is the code, I have already written.
I have taken 'mytime' as unsigned long data type. For this data type, we can save interger value up to almost 4.2 billion. And this value is in milli-second. If we try to find out how many days it can run continuously, then it comes to 49.7 days. After this time the clock overflows and resets to 0.

In void setup code, we only define serial dot begin to communicate with the laptop and display data in serial monitor.

Inside loop code, we only assign millis command value, to mytime and print that in the serial monitor. We have no other commands.

This runs so fast, that we cannot read. So just after 20 seconds, I introduce a delay of 10 seconds, so that we can read the value comfortably.

When I introduce a delay of 10 seconds, then every 10 seconds it gives the output, you can see with almost 1 milli second variations.

So we can use this free running clock to take decisions to perform different tasks.
In the next video we will see what can we do with millis command and what advantages we can take while programming.

#diy #arduino #ArduinoMillis
Рекомендации по теме
welcome to shbcf.ru