This is a post about some things I learned this summer while I was interning in the mechano-electric feedback lab at the University of Oxford, working with computer models of hearts.
A heart removed from the body can be kept beating on its own for up to five hours, if you keep it in a fluid that contains the right dissolved ions and gases. The speed of your heartbeat can be increased or decreased by the nervous system, but creation of the beat is intrinsic to the heart itself.
Heartbeat starts as a rhythmic electrical impulse in a cluster of specialised cells. It's then conducted through the heart, causing the muscle cells to contract at specific times.
The chambers and vessels of the heart
Image from Wikipedia
Each beat of the heart progresses through several stages in sequence. First, when the heart is completely relaxed, the atria are at a lower pressure than the pulmonary vein and the superior vena cava. This pressure difference causes blood to flow into the atria. Then as the atria fill and the pressure inside increases, the mitral and tricuspid valves open, allowing blood to start flowing into the ventricles. Then the muscular walls of the atria contract, forcing more blood into the ventricles.
As the pressure inside the ventricles increases, the mitral and tricuspid valves close - isolating the ventricles from the atria - and the aortic and pulmonary valves open. The ventricles then contract, forcing blood out of the heart. The blood from the right side of the heart goes via the pulmonary artery to the lungs, and the blood from the left side of the heart goes to the rest of the body through the aorta.
Animation of conduction through the heart
Adapted from Wikipedia
The sinoatrial (SA) node is where the electrical signal is created. The impulse is then conducted through the working cells of both atria, inducing them to contract. The signal then passes slowly through the atrioventricular (AV) node, down through the bundle of His and the right and left bundle branches, then up across the purkinje network, and finally through the working ventricle cells. The ventricles then contract from the bottom upwards, and then the heart relaxes until the next beat.
The speed and route that the impulse takes to pass through the heart are very important for proper functioning of the heart. This, and the creation of the beat, are emergent properties of the voltage-gated ion channel systems in heart cell membranes.
Reference: Human Physiology - From Cells to Systems by Lauralee Sherwood (5th Ed) ISBN 0534395015, p.303-330