#### Brien Cheow

##### Newbie level 6

n= First peak time taken

a=Second peak time taken

v= Difference in time between the two peaks

b=Difference in time converted to seconds

f=Calculation for beats per minute

s=Counter for every 10ms overflow from timer0.

Code:

```
{
h= (ADC0>>4);
for(l=0; l<127; l++)
{
if(p<h+5)
{
p=h;
}
else
{
n=s;
break;
}
}
for(l=0; l<127; l++)
{
if(p>h-1)
{
p=h;
}
else
{
break;
}
}
for(l=0; l<127; l++)
{
if(p-1<h)
{
p=h;
}
else
{
a=s;
break;
}
}
v=a-n;
b =v*0^01;
f = (1/b)*60;
for (l=0; l<127; l++)
{
if(p>h-1)
{
p=h;
}
else
{
break;
}
}
}
}
```

Any help is greatly appreciated and thank you in advance