Calculate the average of pulse
How i can calculate the average of pulse sensor? I have tried this code but it didn't worked and even the values didn't showed up in serial monitor and in processing.
`
for(int i=0; i<64; i++)
{ // Average over 16 measurements Signal += analogRead(pulsePin); }
Signal= Signal/64; `
I did this in interrupt.ino where it is reading from A0
Interesting. Well, you are taking 64 readings of the ADC. It takes Arduino (ATmega) about 100uS to do an Analog read. Your loop takes ~6.4mS to complete. There's your problem right there. You need to reduce the number of samples you are averaging. Our Arduino Code interrupts to sample every 2mS. You need to limit the amount of samples you take to >20.
Also, are you resetting the Signal variable to 0? If not, you are just adding and adding to it.
Ok i'll try that... I'm using arduino pro mini and i'm using timer1 as it mentioned that is used 9 and 11 pin and my 9th and 11th pin are not free will it cause a problem or should i use timer2 for pro mini 5v version
which is more stable? and what is the threshold value so that i could minimize the noise
The only thing that the Timer selection does to those pins is not allow you to use PWM. Timer 2 breaks PWM on pins 3 and 11 Timer 1 breaks PWM on pins 9 and 10 You can use those pins for other digital things.
As for the threshold, you will have to play around with the default value of the thresh varialbe in the interrupts
Okay.. please suggest me which timer i should use for pro mini 5v 16mhz ?
You could use either one. Depends on if you want to use PWM on any of the pins. Simple.