I am building a PTZ Camera through Pelco D for which I need to do speed variation with respest to zoom.
The only way, I am thinking of is to measure the time, the serial data for zoom command is coming.
When ever I click for zoom, this command "FF 01 00 20 00 00 21" for 3.5 sec ( 1x to 26x zoom) followed by stop command "FF 01 00 00 00 00 01" when I release the zoom button.
In addition to "software" method, introduced by @J-M-L , I can suggest a "hardwire" one.
Choose any free pin, in the first command apply a high level to it, in the second low - and see the pulse on an oscilloscope or logic analyzer. This method is good because it does not require a monitor and can measure durations in fractions of a microsecond.
If you use a modern AVR (post2016 revolution, 4808/9, tinyAVR 0/1/2 and DA/DB/DC) just use a timerB - or two in cascade mode (tiny2 and Dx only] and measure uip to 234 * system clocks (divide low clock by 2, then use the ovf bit for high bit
I don't need the cascade for my testing, I was trying to figure out how fast a piece of code ran in the tens or hundreds of clock cycles to run so it'd kick off a timer immediately before starting the test in pulse width measurement mode.