An electrocardiogram (ECG) records the electrical activity of the heart over time via electrodes placed on the skin. It detects the heart's electrical dipole by measuring the potential differences between electrodes. The ECG can be used to diagnose conditions like heart attacks, arrhythmias, electrolyte imbalances, and more by analyzing features of the P, QRS, and T waves as well as intervals between them. To perform an ECG, electrodes are attached to the patient's limbs after cleaning the skin. The ECG machine then records the signals from multiple leads to analyze the heart's rate, rhythm, and electrical axis.