If you define
f[x_, t_, nm_] := 1/2 + Sum[1/(n π) ((-1)^n - 1) Sin[n x] Exp[-t n^2], {n, 1, nm}];
then
Plot[Table[f[x, t, 150], {t, {0, 0.01, 0.1, 0.5, 1, 10}}] // Evaluate, {x, -Pi, Pi}]
produces

and the "Gibbs ringing" i.e. the small oscillations near the sharp edges come from truncation of the sum at 150 instead of $\infty$.
Treating separately the t=0
case, which can be summed to infinity (see Sjoerd's answer),
you can get a pretty accurate plot while choosing nm=1000
Show[{Plot[
1/2 + Sum[1/(n π) ((-1)^n - 1) Sin[n x], {n, 1, Infinity}] //
Evaluate, {x, -π, π},PlotStyle-> Darker[Blue,0.5]],
Plot[Table[
1/2 + Sum[1/(n π) Exp[-n^2 t] ((-1)^n - 1) Sin[n x], {n, 1,
1000}], {t, {0.01, 0.1, 0.5, 1, 10}}] //
Evaluate, {x, -π, π}, PlotPoints -> 50]}]
