Projects / Capacitor charge curve

Capacitor charge curve

Intermediate35 minGuided buildReviewed
Arduino UnoD7D6A0GNDCapacitor charge0 s: 0.00 VSerial Plotter
Serial at 115200 baud

Tap a part to see what it does.

Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.

Build it step by step

0 of 4 done
  1. UNO

    Mind the polarity

    Capacitor stripe (−) to GND.

  2. UNO

    Charge path

    D7 through 10 kΩ to the capacitor +, which also goes to A0.

  3. UNO

    Discharge path

    D6 through 220 Ω to the capacitor +.

  4. UNO

    Plot

    Upload and open the Serial Plotter.

In short

How do you build a capacitor charge curve?

An Arduino charges a 100 µF capacitor through 10 kΩ and records the voltage every 20 ms, so you can see the time constant (about 1 second) in the Serial Plotter. You need Arduino Uno R3, Resistor 10 kΩ, Electrolytic Capacitor 100 µF, Resistor 220 Ω and Breadboard 830 Tie Points. It takes 4 steps and about 35 minutes.

Level
Intermediate
Time
About 35 min
Parts
5
See the electronics first. This build uses capacitor charging. Try a capacitor charging in the circuit builder and watch the voltages and currents before you wire it.

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
D710 kΩ to the capacitor +Charging
Capacitor +A0Measure
Capacitor −GNDStripe side
D6220 Ω to the capacitor +Discharge (set LOW)

Code

No libraries. Close the Serial Monitor and open Tools → Serial Plotter at 115200 to see the curve. τ = 10 kΩ × 100 µF = 1.0 s; expect 0.8 to 1.2 s because electrolytics are ±20 %.

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

const int CHARGE = 7, DISCHARGE = 6;

void setup() {
  Serial.begin(115200);
  pinMode(CHARGE, OUTPUT); pinMode(DISCHARGE, OUTPUT);
}

void loop() {
  // empty the capacitor
  digitalWrite(CHARGE, LOW); digitalWrite(DISCHARGE, LOW); delay(2000);
  pinMode(DISCHARGE, INPUT);           // let it float while charging
  unsigned long t0 = millis(); bool marked = false;
  digitalWrite(CHARGE, HIGH);
  while (millis() - t0 < 5000) {
    float v = analogRead(A0) * 5.0 / 1023;
    Serial.println(v);
    if (!marked && v >= 3.16) { marked = true; Serial.print("tau_ms:"); Serial.println(millis() - t0); }   // 63.2 % of 5 V
    delay(20);
  }
  pinMode(DISCHARGE, OUTPUT);
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

2.50
2.51
2.50
2.51
2.50
2.51

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
One cycleCurve rises quickly, then flattens near 5 V
tau_ms lineBetween about 800 and 1200 ms
Swap to 1 kΩCurve about 10 times faster

If it does not work

Straight line at 5 V

Capacitor not connected or reversed.

Never reaches 3.16 V

Leaky or reversed capacitor, or a 100 kΩ resistor by mistake.

Curve starts high

Discharge time too short; increase the first delay.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the capacitor charge curve?

Arduino Uno R3, Resistor 10 kΩ, Electrolytic Capacitor 100 µF, Resistor 220 Ω and Breadboard 830 Tie Points. Resistor 220 Ω: Discharge resistor.

How long does the capacitor charge curve take to build?

About 35 minutes for a intermediate maker, in 4 steps.

How do I know the capacitor charge curve works?

One cycle: Curve rises quickly, then flattens near 5 V. tau_ms line: Between about 800 and 1200 ms. Swap to 1 kΩ: Curve about 10 times faster.

Straight line at 5 V: what should I check?

Capacitor not connected or reversed.

Never reaches 3.16 V: what should I check?

Leaky or reversed capacitor, or a 100 kΩ resistor by mistake.

Curve starts high: what should I check?

Discharge time too short; increase the first delay.