Manipulate[Needs["PlotLegends`"];
xmot=-3.2;xblock=-2;
xplotmin=xmot-0.6;xplotmax=2.1;
yy=(mass/100)^(1/3)/2;
beta=damp/(2mass);
om0=(Sqrt[k/mass]);
delta=Mod[ArcTan[(2w beta)/((om0^2)-(w^2))],Pi];
om1=(Sqrt[om0^2-beta^2]);
fod=k foramp/(mass (Sqrt[(((om0^2-w^2))^2)+4w^2 beta^2]));
phi=ArcTan[beta/om1-(fod w Sin[delta])/(om1 (initpos-fod Cos[delta]))];
x0=(initpos-fod Cos[delta])/Cos[phi];
xoft=oscil[tv,x0,beta,fod,w,delta,om1,phi];
boft=motion[tv,w,foramp];
Column[
{Graphics[{
GrayLevel[1-damp/(Sqrt[4mass k])],Rectangle[{xplotmin,-0.4},{xplotmax,0}],
Orange,Line[{{0,-0.3},{0,0.3}}],
GrayLevel[0.2],Disk[{xmot,yy},foramp],
Blue,Disk[{boft[[1]]+xmot,boft[[2]]+yy},0.03],
Black,Line[{{boft[[1]]+xblock,yy},{boft[[1]]+xmot,boft[[2]]+yy}}],
Red,Rectangle[{boft[[1]]+xblock-0.05,2yy-0.02},{boft[[1]]+xblock,0.02}],
Green,Rectangle[{xoft-yy,0},{xoft+yy,2yy}],
Blue,Line[springform[{boft[[1]]+xblock,yy},{xoft,yy}]],
Black,Line[{{xplotmin,0},{xplotmax,0}}]},
ImageSize->{450,150},Axes->{False,False}, PlotRange->{{xplotmin,xplotmax},{-1.1,1.1}}],

Plot[{Evaluate[oscil[tt,x0,beta,fod,w,delta,om1,phi]], Evaluate[motion[tt,w,foramp]][[1]]},{tt,0,MaxTime},PlotStyle->{{Thick,Black},{Thin,Red}},Epilog->{Green,PointSize[Large],Point[{tv,xoft}]},ImageSize->{450,250},Axes->{True,True}, AxesLabel->{Style["t",14,Bold,Italic],Style["x(t)",14,Italic,Bold]},
PlotLabel->Text[mass x''[t]+damp x'[t]+k x[t]==foramp Cos[w t]],PlotRange->All]}],

{{initpos,1,"initial position"},-1,1,Appearance->"Labeled"},
{{k,3.1,"spring constant"},0.1,10,Appearance->"Labeled"},
{{damp,0.65,"damping friction"},0.05,2.2(Sqrt[mass k]),Appearance->"Labeled"},
{{mass,2.5,"mass"},0.3,9,Appearance->"Labeled"},
{{foramp,0.7,"forcing amplitude"},0.01,1,Appearance->"Labeled"},
{{w,2.4,"forcing frequency"},0.01,5,Appearance->"Labeled"},
{{tv,0,"run"},0,Infinity,ControlType->Trigger},
{{MaxTime,40,"Time interval"},20,100,Appearance->"Labeled"},
Initialization:>{springform[lft_,rgt_]:=Module[{i,dnode,imax},
imax=2*10;
dnode=(rgt[[1]]-lft[[1]])/(2*imax+2);
{lft}~Join~{{lft[[1]]+dnode,lft[[2]]}}~Join~Table[{2i*dnode+lft[[1]],yy+0.1*(-1)^i},{i,1,imax}]~Join~{{rgt[[1]]-dnode,rgt[[2]]}}~Join~{rgt}],
motion[t_,w_,amp_]:=Module[{xco,yco},
xco=amp Cos[w t];
yco=amp Sin[w t];
{xco,yco}],
oscil[t_,x0_,beta_,amp_,w_,delta_,om1_,phi_]:=Module[{},
xco=x0  Exp[-beta*t]Cos[om1 t-phi]+amp Cos[w t-delta]]}
]