u[x_,t_]:=4L Sum[
((Sin[n π/2])/((n^2)(π^2)))Exp[-(((n π/L))^2)(c^2)t] Sin[n π x/L],
{n,1,40}]

c=1;L=2;

Plot[u[x,0],{x,0,L}]

Animate[
Plot[u[x,t],{x,0,L},PlotRange->{0,1}],
{t,0,2}]

Plot3D[u[x,t],{x,0,L},{t,0,2}]

Animate[
DensityPlot[u[x,t],{x,0,L},{y,0,1},AspectRatio->1/10,ColorFunction->"Rainbow",ColorFunctionScaling->False,PlotRange->{0,1}],
{t,0,1,0.1}]

Clear[u]

sol=NDSolve[
{(∂_x)(∂_x)u[x,t]-(1/(c^2))(∂_t)u[x,t]==0,
u[0,t]==0,u[L,t]==1,u[x,0]==Sin[π x/(2L)]},
u,{x,0,L},{t,0,2}]

x+y/.x->4

Plot3D[u[x,t]/.sol[[1]],{x,0,L},{t,0,2}]

Animate[
Plot[u[x,t]/.sol[[1]],{x,0,L}],{t,0,2}]