Deriving ODE for voltage across capacitor-RC circuit I need to derive an ODE for the voltage across the capacitor in a specific RC circuit. The circuit has 1 resistor, one input, one capacitor and a switch.
So far I have 
$$\frac{dv}{dt} =\frac1CI(t),$$
how can I incorporate the switch into this if it is closed between $t=0$ and $t=2$?
 A: If the switch is open, then no current can pass through the circuit. Your ODE should then take the form
$$
\frac{di}{dt}=0\tag{1}
$$
When the switch closes, then current can pass through, leading to
$$
R\frac{di}{dt}+\frac{i}{C}=0\tag{2}
$$
When the switch opens again, we revert the ODE back to Equation (1).
Thus, the time range $0\leq t\leq2$ gives you range for which Equation (2) is valid & does not need to be incorporated into the ODE.
A: Model the current through the resistor as 
$$ i(t) = v(t)/R, $$
the current through the capacitor as you have above, that is
$$ i(t) = C \dfrac{dv}{dt}, $$
and the turning on/off of the switch can be modelled using the Heaviside function which would pre-multiply the above expressions.  The current has to be continuous throughout so we can equate the two expressions to obtain an equation for the voltage evolution.
$$ \dfrac{dv}{dt} = H(t-2)\dfrac{v(t)}{RC} $$
A: You can substitute the switch with a resistor $R_2$, that has a value of either $0$ or $\infty$.
