Then change cathode pin to an input and using pulseIn see how long it takes to drop to a zero.
Ooooo. I thought it was proposed to fix a bug in pulseIn()
, but your example usage of it won't work with the "fixed" version.
See, pulseIn(pin, HIGH)
should wait for a LOW-HIGH transition before starting to time or you may get partial pulse width measurements, but the current version just starts timing it anyway if the pin is already HIGH. If you are timing the discharge of a fast capacitor-like system, waiting for the LOW-HIGH transition first won't work well. You might need to roll your own custom dischargeIn(pin)
function to do it, if they fix pulseIn()