The cardiac cycle consists of two phases, diastole and systole.
Diastole is when the heart is relaxing, allowing blood to flow into the chambers from the vena cava on the right side and the pulmonary vein on the left side. Blood flows into the right and left atria, then into the right and left ventricles through the open tricuspid and mitral valves (known as AV valves). As more blood enters the ventricles the pressure gradient accross the AV valves reverses such that the pressure in the ventricle is higher than the atria and as a result the AV valves close.
Systole is when the heart contracts. After the closure of the AV valves (which produces the first heart sound) the blood in the ventricles is contained in the ventricles as both the semilunar (aortic and pulmonary) and AV valves are closed. The ventricles start to contract thereby increasing the pressure in the ventricles. Once the ventricular pressure reaches a level greater than that in the aorta and pulmonary trunk, the semilunar valves open and blood flows into the aorta and pulmonary trunk.
As the blood leaves the ventricles into the aorta and pulmonary trunk (PT), the pressure starts to rise in the aorta and PT causing the semilunar valves to close (producing the second heart sound).
As blood flows into the atria the atrial pressure starts to increase to a level beyond that in the ventricles causing the AV valves to open, bringing us back to the start of the cycle above.