Learn

Charging and Discharging a Capacitor with a Raspberry Pi 4B (RC Timing Circuit)

Build the classic RC charge/discharge circuit — a capacitor, resistor, two tact switches, and an LED — and watch real RC timing play out on a Raspberry Pi 4B simulator.

Note: the Capacitor is a Premium-tier component in the simulator — you’ll need a Premium or VIP plan to use it there.

Try this directly in the free Raspberry Pi 4B simulator — no hardware or signup required. New to the GPIO header? Start with the interactive pinout guide.

What you’ll need

  • Raspberry Pi 4B
  • Breadboard
  • 2 Tact Switches
  • Resistor (set to 1000Ω)
  • LED
  • Electrolytic Capacitor

Step by step

  1. Drag Raspberry Pi 4B, Breadboard, 2 Tact Switches, a Resistor, an LED, and the Electrolytic Capacitor onto the Canvas.
  2. Set the Resistor's value to 1000Ω (click it to select it, then adjust the value in the settings panel).
  3. Wire the charging path (Switch A): Pi's 5V pin → Tact Switch A → Resistor → the capacitor's + leg.
  4. Wire the discharge path (Switch B): the capacitor's + leg → Tact Switch B → the LED's anode. LED cathode → GND.
  5. Wire the capacitor's − leg → GND.
  6. Click Start.
  7. Press and hold Switch A only (leave Switch B untouched) for a couple of seconds. With nothing clamping it, the capacitor charges freely, so the on-component voltage readout should climb all the way toward the full ~5V. Release Switch A.
  8. Now press Switch B — this connects the LED for the first time. You should see it light up and fade out over a few seconds as the capacitor discharges through it.

How to test it with the Digital Multimeter:

  1. Drag a Digital Multimeter onto the Canvas. Click it and set its Mode to Voltage. Do this while the simulation is stopped.
  2. Wire the meter across the capacitor: Probe (+) → the capacitor's + leg. Probe (− / COM) → the capacitor's − leg.
  3. Click Start. Before you press anything, the meter reads 0.000 V.
  4. Press and hold Switch A for about 2 seconds, then release it. The meter rises toward 5 V while you hold the switch.

What “working correctly” looks like

  • How to test it: the meter rises smoothly toward 5 V while Switch A is held. With a 1 kΩ resistor and the default 470 µF capacitor the time constant is about 0.47 seconds, so after about 2 seconds it reads roughly 4.9 V. After you release Switch A, the reading stays where it was and matches the capacitor's own on-canvas readout, because the capacitor holds its charge. While Switch B is held, watch the capacitor's own readout instead of the meter, because the meter can show 0.000 V during the discharge.
  • The on-component voltage readout climbs smoothly while charging, and counts back down smoothly while discharging — it never jumps instantly to a value.
  • The LED's fade duration roughly matches what you'd expect from τ = R × C for your chosen resistor/capacitance values — a bigger resistor or a bigger µF means a slower fade.
  • Swapping in the Ceramic variant (a much smaller µF) should discharge dramatically faster — often too fast to see with the naked eye, which is itself a correct, realistic result.