I would like to measure the time between 2 serial inputs i am quite new to programming and cant find anything online that will help me accomplish this. Which function should I use to Start a timer from a serial input.
When the first Serial input becomes available save the value of millis() as the start time
When the second Serial input becomes available save the value of millis() as the end time
Subtract start time from end time and you have the period in milliseconds
Which line of code should i use to save the value when the first serial input is availible
unsigned long startTime = millis();
Note that you need to do this when the Serial data becomes available and not repeatedly while the Serial data is available
ali234007:
I would like to measure the time between 2 serial inputs i
You need to explain in detail what you mean by "serial input".
If a serial message contains several characters will you want to measure the time between the start of message A and the start of message B or between the end of message A and the start of message B or ...
...R
Serial Input Basics - simple reliable non-blocking ways to receive data.
Also why do you want to do this? Don't want an xy problem