The system $u_{tt}-u_{xx} \ni f$, $x \in (0,L) \times (0,T)$, with initial data $u(x,0) = u_0(x)$, $u_t(x,0) = u_1(x)$ almost everywhere on $(0, L)$ and boundary conditions $u(0, t) = 0$, for all $t \geq 0$, and the unilateral condition $u_x(L, t) \geq 0$, $u(L, t) \geq k_0$, $(u(L, t)-k_0)u_x(L, t) = 0$ models the longitudinal vibrations of a rod, whose motion is limited by a rigid obstacle at one end. A new variational formulation is given; existence and uniqueness are proved. Finite elements and finite difference schemes are given, and their convergence is proved. Numerical experiments are reported; the characteristic schemes perform better in terms of accuracy, and the subcharacteristic schemes look better.