Go Down

Topic: Counter variables with analogRead (Read 417 times) previous topic - next topic


So I think you need to put the first part of your code, ie determine the peak value, in the setup, and the test, ie 10 readings, in the loop.
The issue with doing what you're saying is, I get stuck with a particular peak value for as long as I don't reset the arduino. And depending on the stability of the heart beat, that initial peak may have been a fluke and new peak will need to be found.


Mar 25, 2019, 07:59 am Last Edit: Mar 25, 2019, 08:12 am by PaulRB
This is a very different requirement to anything you mentioned in your original post (which, by the way, you have still not corrected by adding code tags).

I suggest a new algorithm which maintains a running average of the readings, and a running Mean Absolute Deviation (MAD) from that average. Then, peaks can be detected that exceed the average plus 150~200% of the MAD.

Go Up