A pacemaker is a medical device that generates electrical impulses delivered by electrodes to contract the heart muscles and regulate the electrical conduction system of the heart.