int dist_threshold = [color=red]7.85[/color]; => does not really looks like an int to me....
[color=red]int[/color] readsensor()
{
...
[color=red]long cm[/color]= duration / 29 / 2; //calculate the distance in cm
return cm;
}
Same comment here, bad type
Your code does not meet what I asked in #1
Start with just that, get rid of everything else