Arduino - How to Compute a Duration with micros()

preview_player
Показать описание
Learn how to compute the duration of any action in your Arduino program - using the micros() function to get the time.

0:00 Intro
0:10 Why it’s important
0:45 Compute the duration of an action with micros()
2:25 Use the duration in your code (ex: print it)
3:44 Convert the duration in seconds
5:02 Recap
5:43 Outro

Рекомендации по теме
Комментарии
Автор

for the time to be displayed more accurate you have to use the dtostrf() function which converts the float/double to a string iirc

ipadize
Автор

you can also write this: ") + (duration));

that makes it a little more tidy

ipadize
Автор

Very nice and very useful. Thanks for sharing.

TRCVJU
Автор

Tres bien! You are very good at explaining a principle very clearly. Thank you.

johnx
Автор

Thank you for explaining this function. I have got an encoder signal from a slow running motor, and I guess a way could be to measure the time between pulses using this micros function. I guess some hardware counter is used and you read that counter by micros. I looked in the hardware description for ATmega328P, but could not identify this counter. Do you know the name of this counter?

sewingmachinesindetail