4 years, 1 month ago.

how can I adjust this code for pulse sensor on bed nxp lpc1768

I found this code (https://os.mbed.com/users/donalm/code/PulseSensor/) that shows the pulse on a graph using visualizer. All I need is to show the value of the BPM (without the graph) but I'm not sure how to change the code. I’m a beginner at mbed and sensors as a whole. Can someone please help?

1 Answer

4 years, 1 month ago.

Did you try running that code?

It doesn't plot anything, that's being done by a PC application that reads the serial port.

That code outputs 3 possible lines of text on the USB serial port at 115200 baud.


is output at a fixed interval (20 ms currently, you can change the time by setting it in the sensor constructor e.g. PulseSensor sensor(p15, sendDataToProcessing,50); for 50ms.


Q[Time between beats]

Are both output after the sensor value whenever there is a new value to report.

If you want to change the output the only output BPM without the B prefix easiest thing to do would be change the void sendDataToProcessing() function in main.cpp to something like:

void sendDataToProcessing(char symbol, int data)
  if (symbol == 'B')
      pc.printf("%d\r\n",  data);