This is the original project I found for detecting pulse rate using a Kinect.
Afterwards, I found this Python webcam pulse detector.
![](https://cdn.hackaday.io/images/4519621536342226178.png)
I forked that project to here: https://github.com/dwaq/webcam-pulse-detector to make my own modifications.
- I uncommented the Serial calls and documented how they worked in the README
- I changed the format that the data is sent over serial. It was sent as a string, but I sent it as a one-byte integer to make it easier on the receiving microcontroller.
- I added a delay between each serial message so it would not overwhelm the Digispark's virtual comm port. I tried to make this work with threading, but I didn't understand why it wasn't working. So instead I added a simple (hacky) counter that works to delay the message 25x slower than normal. I can think of two ways to improve this:
- use a microcontroller with a hardware-based serial port may be able to handle the unrelenting rate of the messages
- Use the hardware PWM to set the LED timing. I'm using delays because there wasn't an easy way to adjust the frequency of the Arduino library's analogWrite()
![](https://cdn.hackaday.io/images/original/6829151536617998891.gif)
This is the process on the microcontroller side:
- Read the pulse sent over the serial as a BPM (beats per minute) pulse
- Convert that to beats per second
- Invert that to determine the period of a beat
- Set the on time of the LED to 3/8 of a beat
- Set the off time of the LED to 5/8 of a beat
- Set the LED high
- Delay for the on time
- Set the LED low
- Delay for the off time
- And repeat...
![](https://cdn.hackaday.io/images/2127631536341009788.png)
According to Wikipedia, for a typical heart rate of 75 BPM, the cycle requires 0.3 sec in ventricular systole and 0.5 sec in diastole. I asked my wife (who is a nurse) and did research online and could not determine if systole is always 0.3 sec, or always 3/8 of the pulse. I assumed that it's always the same proportion of the pulse, so I chose 3/8 of the period for light on and 5/8 of the period for light off. If anyone knows, I would love to make this blinking more realistic and update the project accordingly.
Is it possible to put the link of the used sensor that contains a light?