Question about a counter

Hey i try use a HC-SR04 distance sensor to counter, in my program i need count peoples in 40cm distance, my distance sensor works well but i can't count the persons what i make wrong ?

Here is my cod:

const int trigPin = 11;
const int echoPin = 10;

long duration;
int distance;

void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}

int Distance(int distance, long duration){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distance = duration*0.034/2;

/Serial.print("Distancia: ");
Serial.print(distance);
Serial.println(" cm");
/
}

int counter;

void loop() {
int distancia = Distance(distance, duration);
if(digitalRead(distancia)<10)//checa o input
{
while(digitalRead(distancia)<10)//espera o input para o fim
{};

counter+=1; //incremento para contar as pessoas
Serial.println(counter);
delay(50);
}

}

if(digitalRead(distancia)<10) Zero or one will always be less than ten.
I don't know which pin you're reading from either.

Please remember to use code tags when posting code

Since 'distancia' is probably intended to be your distance in cm I guess you should be comparing that in your if...not trying to do a digitalRead of it as though it was a pin number.

But first you need to actually return it from the Distance() function which claims to return an int but has no return statement anywhere in it.

Steve