Not getting readings from capacitor

arduinocapacitor

I'm trying to read capacitor output values as the cap discharges for a physics project, and am getting a high voltage while charging, but dropping to 0V 3000 \$\mu\$s after stopping the charging signal, which doesn't seem right.

Schematic:
Arduino Schematic

The cap is 1mF, resistor 1k\$\Omega\$.

I'm trying to charge the cap by sending +5V out through the digital line for 2 seconds, and then trying to discharge by either switching the digital output line to high-impedance (by switching it into input mode, pinMode(DIGITAL_OUTPUT, INPUT);) or by writing a low signal (digitalWrite(DIGITAL_OUTPUT, LOW);).

I've tried both methods of triggering discharge, but the analog signal that I've read (analogRead(ANALOG_INPUT);) has gone from +5V while charging down to 0V 3000\$\mu\$s after. I was under the impression that the cap should take at least 2 seconds to fully discharge.

I assume I've messed up the circuitry somehow, and the code is actually working after enough debugging, so I haven't wasted space with 97 lines of code, but the code is in a pastebin if the circuit looks like it should work.

Best Answer

Are you sure the capacitor is 1mF (1 milliFarad) as opposed to the more common value of 1uF (1 microFarad). A 1 uF capacitor with a 1 K resistor would give you a time constant of 1000 us, so after 3000 us, you should expect to see a voltage of < 5%.