I'm wanting to build a computer keyboard-to-display lag measuring tool using an Ardunio:

  1. User places the photosensor right-up to their computer monitor.
  2. User presses a button on the Ardunio.
  3. The button press starts a high-resolution timer on the Arduino and also sends-out a USB HID mouse-move event to the computer.
    • Using mouse-move events means the computer would use the hardware cursor which eliminates the frame (16ms) of lag caused by using desktop composition in most modern desktop computer operating-systems.
    • The mouse cursor on the display itself would be pre-positioned so be directly visible by the photosensor, so when the mouse-move event is handled the color of the pixels where the mouse is would change.
  4. The Arduino then looks for changes in photosensor output that would indicate the mouse cursor (or rather: display pixels) had changed and then report the timer readings to determine end-to-end lag.

My thought was to set my mouse-cursor to be a big black cursor over a white background and use a simple photoresistor, but I learned that photoresistors have a physical lag up to 10ms from dark-to-light and up to 1000ms for light-to-dark which may make it unsuitable for my application where I'd like to reliably measure end-to-end lag within 1ms - so using a photoresistor is probably not appropriate.

My fall-back idea is to use the Ardunio to fire off a USB event while simultaneously lighting an LED directly attached to the Arduino board (so there should be effectively zero latency between pressing the button and the light coming on) and then using my iPhone's 240fps camera (4.2ms resolution) to record the time between the LED being lit and my computer display changing. As I run it at 60Hz, a 4.2ms resolution is (barely) sufficient - but ideally I'd like sub-1ms measurements.

My questions:

  • Would a photocell like this begin to change its output within 1ms of detecting a change or would the signal be too noisy or meaningless without waiting the 10ms (for dark-to-light changes).
  • What other sensors could be used to detect any change in light (either light-to-dark, dark-to-light, color changes, etc) with minimal latency such that an Ardunio could detect the change within 1ms of it happening in real-life?
  • \$\begingroup\$ 1ms is an eternity as far as photodiodes and phototransistors go, even the slow ones. I know you describe what you are trying to sense but you never mentioned whether you need a graduated signal or just on/off. Phototransistors are the easier of the two to use by far, but are much better suited for on/off rather than graduated readings, though they can be pressed into service for graduated readings if you really want to. \$\endgroup\$
    – DKNguyen
    May 24, 2020 at 4:16
  • \$\begingroup\$ The USB polling interval is on the order of milliseconds, too. And it will be different each time since it isn't synchronized to your move event. Something else to take into consideration. \$\endgroup\$
    – gbarry
    May 24, 2020 at 5:17
  • \$\begingroup\$ @gbarry Indeed. Though my real-life mouse is configured to use a 500Hz poll-rate, so I'm hoping I can configure my Arduino to support 500Hz or even 1000Hz USB poll rates. \$\endgroup\$
    – Dai
    May 24, 2020 at 6:51
  • \$\begingroup\$ On the chance you can catch the USB interrupt or the poll event, you could set your timer against that. Otherwise do a bunch of tests and take the lowest result. \$\endgroup\$
    – gbarry
    May 24, 2020 at 9:04

2 Answers 2


Look into reverse biased / avalanche detection of photo diodes, usually fed to a transimpednace amplifier, the response time can be nanoseconds,

For a start on reverse biased, here is the general schematic, when the brightness changes, the current changes very sharply, and you get a fast voltage rise.

enter image description here

Image Source

Avalanche is when you need it to respond even faster / sharper, but has a longer recovery time, generally its similar to this, but the bias voltage of the op amp is increased until its just below the reverse breakdown voltage threshold, this decreases with small increases in light intensity.

  • 1
    \$\begingroup\$ Your schematic is unlikely to work with an APD, since the APD will need 50-400 V bias to put it on the edge of avalanche conduction. \$\endgroup\$
    – The Photon
    May 24, 2020 at 4:29
  • 1
    \$\begingroup\$ Also, APDs are not generally faster than other photodiodes. In fact the avalanche action tends to increase the time needed for carriers to clear the active region after an input pulse, making them slower. The fastest photodiodes I know are operated with just a few volts bias, but are designed for exceptionally low junction capacitance. \$\endgroup\$
    – The Photon
    May 24, 2020 at 4:32
  • \$\begingroup\$ You talk about operating the photodiode with reverse bias, but the depicted schematic has it zero-biased. \$\endgroup\$ May 24, 2020 at 5:53
  • \$\begingroup\$ Even in PV mode like this circuit, a photodiode should be plenty fast enough for this application. \$\endgroup\$
    – user16324
    May 24, 2020 at 14:42

Those photoconductive cells have about 8Khz maximum speed, so yes, in the right circuit they will respond fast enough to measure millisecond events.

Their response is kind of slow and mushy though, but after 1 millisecond there will definately be some change.

a phototransistor or photodiode will be faster.

  • \$\begingroup\$ What is the right kind of circuitry? Does the OP need to be driving them with a current source or something? \$\endgroup\$
    – DKNguyen
    May 24, 2020 at 5:16
  • \$\begingroup\$ it depends how he's sensing it. reisitive bias and a comparitor could work if the threshold is set close enough to the starting point. they seem more linear with fixed voltage bias (into a common base, or transimpedance amplifier) but linearity is not important in this application. \$\endgroup\$ May 24, 2020 at 5:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.