Your counts are so high because you continue to add to the counts whilst the sensor value remains high.
Try something like this (untested)
long measurementStartTime = 0;
int beats = 0;
byte sensorPin = A0;
int currentSensorValue;
boolean counted = false;
void setup()
{
Serial.begin(9600);
pinMode(sensorPin, INPUT);
}
void loop()
{
if ((millis() - measurementStartTime > 10000) && (beats > 0)) //time is up
{
Serial.print("Beats read in 6 seconds : ");
Serial.println(beats);
measurementStartTime = millis();
beats = 0;
}
currentSensorValue = analogRead(sensorPin);
if (currentSensorValue > 156 && counted == false)
{
beats++;
counted = true;
}
else if (currentSensorValue < 146)
{
counted = false;
}
}
NOTE - the tests deliberately do not use the same value to allow some tolerance as the signal changes from high to low and vice versa but may need adjusting.