once you've done it it's quite easy to understand
here's some quick and dirty code i rushed but i've tried to explain each action, there are better ways but this explains the principal
// LED with current limit resistor connected to digital pin 2 & 3
// LED - to pin 2 & LED + to pin 3
void setup()
{
Serial.begin(9600);
}
void loop()
{
long t=0;
// --------- LED Forward Voltage ------------
pinMode(2, OUTPUT); // LED - to pin 2
pinMode(3, OUTPUT); // LED + to pin 3
digitalWrite(2, LOW); // Make pin 2 0v
digitalWrite(3, HIGH); // Make pin3 VCC
delay(10);
// ------------------------------------------
// --- Now Reverse Polarity to charge LED ---
pinMode(2, OUTPUT); // LED - to pin 2
pinMode(3, OUTPUT); // LED + to pin 3
digitalWrite(2, HIGH); // Make pin 2 VCC
digitalWrite(3, LOW); // Make pin3 0v
// ------------------------------------------
// --------- Now Discharge the LED ----------
pinMode(2, INPUT); // make pin 2 input
pinMode(3, OUTPUT); // pin 3 still output
digitalWrite(2, LOW); // make pin 2 low, it is now input
digitalWrite(3, LOW); // Make pin3 0v
// now count how many loops until pin 2 becomes logic low and LED is discharged
while(digitalRead(2) == HIGH)
{
t++;
}
Serial.println(t); // report to serial
// ------------------------------------------
}