Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. void loop() {
  2. // read the value from the sensor:
  3.  
  4. starttime = millis();
  5. while (millis()<starttime+10000) // so i'm reading the pulse for 10 seconds
  6. {
  7. sensorValue = analogRead(sensorPin);
  8. if (sensorValue >550 && counted == false) // counting the pulse, and making sure I dont count
  9. { // each peak more than once
  10. count++;
  11. counted = true;
  12. }
  13. else if (sensorValue < 500)
  14. {
  15. counted = false;
  16. }
  17. }
  18.  
  19. heartrate = count*6; // multiplying by six to get pulse per minute
  20. Serial.println(heartrate); // printing to serial screen
  21.  
  22. heartrate=0;
  23. count =0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement