How do cardiac pacemakers work?

Modern pacemakers usually have multiple functions. The most basic form monitors the heart's native electrical rhythm. When the pacemaker wire or "lead" does not detect heart electrical activity in the chamber – atrium or ventricle – within a normal beat-to-beat time period – most commonly one second – it will stimulate either the atrium or the ventricle with a short low voltage pulse. If it does sense electrical activity, it will hold off stimulating. This sensing and stimulating activity continues on a beat by beat basis and is called "demand pacing". In the case of a dual-chamber device, when the upper chambers have a spontaneous or stimulated activation, the device starts a countdown to ensure that in an acceptable – and programmable – interval, there is an activation of the ventricle, otherwise again an impulse will be delivered.

Pacemakers or cardiac pacemakers usually refer to artificial cardiac pacemakers, since our body has a natural cardiac pacemaker. 

The artificial cardiac pacemakers work by detecting electric signals through the conductive leads that are attached to the inside of heart walls, usually in atriums, and, in the absence of an electrical signal, generate one to stimulate the desired heart area, either an atrium or a ventricle.