distance sensor and timing

if (elapsedTime > 5000 && distance < 20)
{
  n++;
}