If the mass of the pendulum bob is $m$, the length of the "arm" is $l$, and the angle the arm makes with the vertical is $\theta$, the speed $v$ of the bob is
$v = l\dot \theta; \tag 1$
it follows that the kinetic energy is
$T(\dot \theta) = \dfrac{1}{2}mv^2 = \dfrac{1}{2}ml^2 {\dot \theta}^2; \tag 2$
furthermore, if we assume that the "rest" position of the pendulum, where it is hanging "straight down", is at $\theta = 0$, then the potential energy is
$V(\theta) = mg(l - l \cos \theta) = mgl(1 - \cos \theta); \tag 3$
the Lagrangian for this system is then
$L(\theta, \dot \theta) = T(\dot \theta) - V(\theta) = \dfrac{1}{2}ml^2 {\dot \theta}^2 - mgl(1 - \cos \theta); \tag 4$
the cannonical momentum associated with the coordinate $\theta$ is
$p_\theta = \dfrac{\partial L(\theta, \dot \theta)}{\partial {\dot \theta}} = ml^2\dot \theta, \tag 5$
which, according to the usual prescription, leads to the Hamiltonian
$H(p_\theta, \theta) = p_\theta \dot \theta - L(\theta, \dot \theta) = ml^2 {\dot \theta}^2 - \dfrac{1}{2}ml^2 {\dot \theta}^2 + mgl(1 - \cos \theta)$
$=\dfrac{1}{2}ml^2 {\dot \theta}^2 + mgl(1 - \cos \theta) = \dfrac{p_\theta^2}{2ml^2} + mgl(1 - \cos \theta), \tag{6}$
from which we may directly write Hamilton's equations of motion:
${\dot p}_\theta = -\dfrac{\partial H(p_\theta, \theta)}{\partial \theta} = -mgl\sin \theta, \tag 7$
$\dot \theta = \dfrac{\partial H(p_\theta, \theta)}{\partial p_\theta} = \dfrac{p_\theta}{ml^2}; \tag 8$
using (5) in (7) we find
$ml^2 \ddot \theta = -mgl\sin \theta, \tag 9$
or
$\ddot \theta = -\dfrac{g}{l} \sin \theta, \tag{10}$
readily recognizable as the equation of motion of the simple pendulum; on the other hand, (8) yields
$\dot \theta = \dfrac{ml^2 \dot \theta}{ml^2} = \dot \theta, \tag{11}$
an identity.
It is readily seen from (6), again using (5), that
$H(p, q) = \dfrac{p_\theta^2}{2ml^2} + mgl(1 - \cos \theta) = \dfrac{m^2l^4 \dot \theta^2}{2ml^2} + mgl(1 - \cos \theta)$
$= \dfrac{ml^2 \dot \theta^2}{2} + mgl(1 - \cos \theta) = T(\dot \theta) + V(\theta), \tag{12}$
the sum of the kinetic and potential energies of the pendulum,i.e., the net energy of the system. As such, we should expect it to be constant along the trajectories of the equations of motion (7), (8); it remains the same as the system evolves, hence the term, "constant of the motion." Sometimes the fact that $H(p, q)$ is constant along system trajectories is known as the conservation of energy".
We can see this analytically by differentiation $H$ with respect to $t$:
$\dfrac{dH(p, q)}{dt} = \dfrac{\partial H(p_\theta, \theta)}{\partial p_\theta} \dot p_\theta + \dfrac{\partial H(p_\theta, \theta)}{\partial \theta} \dot \theta = \dot \theta \dot p_\theta - \dot p_\theta \dot \theta = 0, \tag{13}$
by vitue of (7) and (8).