how to count pulse by arduino?

guys im doing a project and want some help. I'm using a IR pulse sensor to get the pulse signal from my index finger but can't calculate the pulse rate. please help me with the code.

Here is what i thought might help is to use pulseIn() function to measure the length of one pulse. this pulseIn() function returns in milliseconds. so if we divide 60000 millisecond by the value we got from the pulseIn() function we might get the pulse rate. but its not working. help me please.

Welcome to the Forum. Please read these two posts: How to use this forum - please read. and Read this before posting a programming question ...

We have no idea how to solve your problem because we can't see it. Please post your code using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpreted by the forum code as italics or funny emoticons.

Unless the sketch is too large, it's better if you post your code, rather than attach it. When it's attached, we have to download it, create a folder then open your code in our IDE. Or perhaps open it in WordPad, which isn't very good for looking at code. And afterwards, the folder remains unless we navigate to the "Temp" folder and manually remove it. It's much easier to just view the code in your post.

Many questions can be answered by reading the documentation which is provided with the IDE, available under the help tab, or online here.

There are many other things that programmers do to make their code understandable. Please do them, as a courtesy to the members who volunteer their time to help you here. One is to use a standard indentation to clearly show the code blocks. Never put more than one statement per line. Place any brackets by themselves on a separate line. Before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read. Another is to give things descriptive names. You can name numerical constants, pin numbers, variables and many other things in this way.

Yadda yadda.

will do thanks

void setup() {
  Serial.begin(9600);
}
void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  int pulse = pulseIn(A0,HIGH);
  int pulseRate = (60000/pulse);
  Serial.println(pulseRate);
}

Is this code is ok??

What is the analogRead() there for?

for viewing the pulse in serial plotter. I want to both visualize and count my pulse rate..

Do you know what the output of the senor is? voltage or digital pulses
Give us a link to it.

If the output of the sensor is an analog voltage, you will need to condition it to digital with a transistor or more likely a voltage comparator.
Then you can use the digital signal in your sketch.

the output of the pulse sensor is analog

the signal from the pulse sensor is varying from 0 to 1023 in serial monitor. Is there any function within the arduino for its analog input pins to convert the incoming analog signal to a digital one??? I'm using arduino uno.

bunny_1994:
the signal from the pulse sensor is varying from 0 to 1023 in serial monitor. Is there any function within the arduino for its analog input pins to convert the incoming analog signal to a digital one???
I’m using arduino uno.

Well, you can cheat and get a very simple comparator function from it by just reading it as digital. It will be HIGH if approximately VCC/2 or more, and LOW if approximately VCC/2 or less.

Also, a link to the sensor has been requested in reply #6 and we are still waiting…