I'd like to measure a dozen potentiometers with an Arduino UNO. Unfortunately, the UNO only has 6 analog pins, but it does have about a dozen digital pins.

Could I effectively measure an analog value with a digital pin by following this procedure?

  1. Wire the potentiometer in parallel with a capacitor.
  2. Connect one junction to an Arduino's digital pin.
  3. Set this pin to write HIGH until the capacitor fully charges.
  4. Set pin to read LOW and then use pulseIn() to measure the time it takes for the capacitor to discharge across the potentiometer, causing the voltage at the pin to go from 5V to 0. This time should be proportional to the resistance of the pot. e.g. a pot with a low resistance will cause the cap to discharge very fast, whereas a high resistance will cause the cap to discharge more slowly.
  • \$\begingroup\$ Yes, old PC joysticks used to use this technique. \$\endgroup\$
    – pjc50
    Mar 17, 2015 at 23:01
  • \$\begingroup\$ Use an external ADC As Reid mentioned, or an analog mux to connector serveral analog inputs to a single A/D input. \$\endgroup\$
    – Oliver
    Dec 4, 2015 at 12:38

3 Answers 3


I would not rely on it. While it may work there could also be some stray capacitance or other factors that also affect the reading of time and voltage value. Remember that there is a no mans land between high and low (where the analog signal would be), that theoretically could change with temperature, time or any variety of other reasons and invalidate your setup. It also relies on knowing the precise time of discharge. Keeping time like this is something that is very hard to do accurately on any microcontoller.

Take for instance you get this to work and calibrate it so that you know that it reads low when the input gets to 1.7v. But come back in a day (or even minute) later and that 1.7v threshold is now 1.6v. The calibration you did would be invalid and you would be getting bogus results.

What I would do instead is use the digital pins to read an external ADC over an SPI or other digital line. This has the benefit of being more reliable and (in most cases) more accurate as well.

So to answer your question, it is theoretically possible. It would be a tough circuit to design, you would need to disconnect the line being monitored while you charge the capacitor, but it could be done. However it most likely would not be very reliable.


The optimal design will depend upon how often the pots need to be read, how stable the values need to be with time (e.g. if you set the pot to a particular position today, will you care if it reads slightly higher or lower tomorrow?), and how reliably small the wiper resistance is compared with the overall pot resistance.

Wiring a pot as a rheostat (one end disconnected) with some resistance is series, discharging a cap, and then timing how long it takes for the cap to charge to VDD through the pot+resistor combo is a very old technique which was used in the original Pong machine and many game machines since; I'm not sure if the Odyssey which predated Pong used the same technique. The biggest problems with that technique are that long-term stability may be poor, and variations in wiper resistance may yield nasty control response if pots get old and/or dirty.

Another approach is to wire the ends of the pot between VDD and VSS, probably with some resistors to keep the wiper voltage some distance from the rails, and then use a comparator to detect whether the pot voltage is higher or lower than a cap-generated reference voltage which ramps from VSS to VDD. Ideally one should use a constant-current source to charge the cap, but if one doesn't get too close to VDD or VSS even a resistor may be "linear enough".

I like the second approach better than the first, since as Atari 2600 owners can attest, rheostat-style controllers get "jittery" after awhile as a consequence of the changing wiper resistance. The second approach would require a couple of quad-comparator chips to read six pots, however, while the former would not.


If you could constant-current discharge the cap, and use a real comparator, this would be much like a slope-based A/D. It's a common way to deal with thermistors. Depending on how big the cap is, and the speed of your timers, this method can have better resolution than an on board A/D. I recommend a real comparator, though.


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.