My experience with p5.js seldom touched upon interaction or animation, so I incorporate mouse in my code. I move a small circle across the screen repeatedly, forming a thin line with trajectory. When the mouse is pressed, the line will dance up and down. You are the one to decide whether the electrocardiogram is live or dead.