How do pacemakers and defibrillators work? A cardiologist explains how they interact with the electrical system of the heart