A pacemaker is a medical device that sends electrical pulses through electrodes to contract the heart muscles and control the…