Check your Heartbeat with KY-039 and Arduino — Easy Beginner Project

Want to see your heartbeat on a computer using Arduino? In this simple DIY guide, you’ll build a basic Heartbeat Monitor using the affordable KY-039 sensor and an Arduino Uno. No advanced electronics skills required — perfect for students, hobbyists, and beginners learning sensors.

Why build a heartbeat monitor?

  • Learn how pulse sensors work in real life.
  • Practice Arduino analog readings and Serial Monitor output.
  • Great for school projects and hands-on learning.

What is the KY-039 heartbeat sensor?
The KY-039 is a budget-friendly sensor that uses an infrared LED and a phototransistor to detect tiny changes in blood flow through your finger. Each heartbeat slightly changes how much light is reflected back to the sensor. The KY-039 converts those small light changes into an analog voltage to the Arduino, so it can read.

Components Required

Sr. No.ComponentQuantity
1Arduino Uno ➤ https://amzn.to/4dBgpHp1
2KY-039 Heartbeat Sensor Module ➤ https://amzn.to/4xl6HjU1
3M-F Jumper Wires ➤ https://amzn.to/430CfOo3
4USB Cable1

Circuit Connections

KY-039 SensorArduino Uno
Vcc +5V
GND –GND
SA0

Code



int sensorPin = A0;


int threshold = 550;
boolean beatDetected = false;


unsigned long lastBeatTime = 0;
int bpm = 0;


void setup() {
  Serial.begin(9600);
}


void loop() {


  int signal = analogRead(sensorPin);


  if(signal > threshold && !beatDetected) {


    beatDetected = true;


    unsigned long currentTime = millis();
    bpm = 60000 / (currentTime - lastBeatTime);
    lastBeatTime = currentTime;


    Serial.print("Heartbeat! BPM: ");
    Serial.println(bpm);
  }


  if(signal < threshold) {
    beatDetected = false;
  }


  delay(20);
}

Common problems and fixes

  • No output: Check wiring, select correct COM port, and confirm the correct sketch is uploaded.
  • Random spikes: Re-seat wires and try another finger; ensure the sensor’s LED and phototransistor are not obstructed.

Limitations and safety

  • This is an educational project, not a medical device.
  • Measurements are approximate and depend on finger placement and movement.
  • Not suitable for medical diagnosis or critical monitoring.

Leave a Reply

Your email address will not be published. Required fields are marked *

More Articles & Posts