Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Not politically correct, but the way I remember it is "Civil Engineers are queer", i. e. C*ΔV=Q, or the the charge stored in the capacitor Q Coulombs = the capacitance C Farads times the change ΔV in Volts as the capacitor is either charged or discharged.
You also need to know that an Ampere of current is a Coulomb of charge per second, I=Q/Δt.
Substituting and rearranging gives:
Q=I*Δt and Q= C*ΔV, so I*Δt=C*ΔV
or C = I*Δt/ΔV
So to only allow a 1V drop (20% if 5V) while delivering 100mA for 4ms, you would need 0.1*0.004/1 = 4e-4 = 400e-6 = 400uF.
the above calculations assume that the output resistance of whatever you are charging the capacitor with is low enough to bring the voltage back up in a reasonable amount of time.
another way of thinking about it is if it is discharging (supplying current) for 100% of the time, and charging for 1/3 of the time, the current supplied by whatever is charging has to be 3 times the LED current.
It is not a good idea to hook a microcontroller directly up to a capacitive load like this.