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.

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.

What “working correctly” looks like

  • 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.