Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void loop() {
- // read the value from the sensor:
- starttime = millis();
- while (millis()<starttime+10000) // so i'm reading the pulse for 10 seconds
- {
- sensorValue = analogRead(sensorPin);
- if (sensorValue >550 && counted == false) // counting the pulse, and making sure I dont count
- { // each peak more than once
- count++;
- counted = true;
- }
- else if (sensorValue < 500)
- {
- counted = false;
- }
- }
- heartrate = count*6; // multiplying by six to get pulse per minute
- Serial.println(heartrate); // printing to serial screen
- heartrate=0;
- count =0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement