Hi btw
I've looked at the code you posted again.
The counters are in this part ...
if(inches < 20)
{
count++;
}
else(inches2 < 20);
{
count--;
}
First thing I spot in this is the ";" after "(inches2 < 20)". I think this makes the code after it, the curly brackets with "count--", a statement on its own outside the if / else. In which case, maybe it is being executed every time round the loop, which is why the counter is only counting down.
Was the following what you meant it to be?
if (inches < 20)
{
count++;
}
else if (inches2 < 20)
{
count--;
}
If this works, then there is another thing to think about. Your main loop repeats after a 500ms delay. So roughly twice a second you increase or decrease the counters depending on whether you get echoes. But won't a car take longer to pass the sensor than half a second? I think you code will keep counting so long as the car is there. Or have I misunderstood?
Regards
Ray