A pacemaker is a battery-operated medical device that is used to treat arrhythmias (irregular heartbeat). It is implanted under the skin of the chest and sends electrical impulses to the heart muscle.