How do cardiac pacemakers work?

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.