heart rate monitor sketch serial data scale maxing

hi im using this sketch from the book arduino projects for the evil genius and it doesnt seem to be working. The data in the serial interface which should potentially be used to create a pulse rate graph, maxs out at 1023, the scale of the reading being between 0 and 1023. Has anyone any ideas where i may be going wrong, thanks:

int ledPin = 13;
int sensorPin = 0;

double alpha = 0.75;
int period = 20;
double change = 0.0;

void setup()
pinMode(ledPin, OUTPUT);

void loop()
static double oldValue = 0;
static double oldChange = 0;
int rawValue =
double value = alpha * oldValue

  • (1 - alpha) * rawValue;


oldValue = value;

Good point Richard

I am using a simple circuit consisting of a IR LED and a IR phototransistor, this shines through your finger detecting your pulse by the variation in the data produced in the serial monitor. This is a bit embarrassing but how do you load a pic from your desktop using the html creator
/Users/christopherlaw/Desktop/max:msp/BLOG STUFF/20101101
/Users/christopherlaw/Desktop/max:msp/BLOG STUFF/20101101

I have checked the code rigorously and it came straight out of the book. All the components were the exact components with the exact codes given in the book from the suppliers. You would be given for thinking this is a fool proof setup he
thanks for your feedback
thanks for your feedback

maxs out at 1023

Because that's the way analogRead works. Why are you expecting something different?


hey my circuit is set up here. Its a very simple circuit with a IR led and a IR photo transistor. Ive since removed the Led and the resistor as its unnecessary.there is only 1 data input to analogue A0.

Richards right, thats the problem

I would have thought that his values would be in the range of 0~1023 if his circuit is designed properly.

I would too. He didn’t say that he wasn’t getting values lower than 1023, though. Only that he wasn’t getting numbers higher than that.