Trying to make a heart rate analyser with Arduino that will calculate the BPM of a person
// Record the start time into time1
if(count==0) {
  time1=millis();
}

// Set time2 to the current time
time2=millis();

// Read the sensor
sensorValue = analogRead(sensorPin);

// If the sensor value is high enough, increment the beat counter
if(sensorValue&gt;156) {
  increment();
}

// If the current time is greater than, or equal to, the start time 
// plus 10,000 milliseconds (10 seconds), show the heart rate
if(time2&gt;=time1+10000) {
 counter();
}