infrared obstacle avoidance sensor used as counter (parking lot system)

I'm working on a project that counts the number of cars that parks in the parking lot and the number of vacant and occupied space within a certain time. Placing the sensors on the top of parking space to detect if it's vacant or occupied at the same time it counts how many were detected. For my prototype, I'm using only 2 ir sensors.

I'm having trouble in may the algorithm and some syntax because I'm a newbie in arduino.
anyone can help me with this? please?
thanks a lot.

int pin=4;
int counter=0;
int detected=false;

void setup() {
  Serial.begin(9600);
  pinMode(pin,INPUT);
}


void loop(){
  
}
void count() {

    int val=digitalRead(pin);
  if( (val == 0) && (detected == false )  ){
          ++counter;
          detected = true;
          delay(2000);
         
          Serial.print("Occupied =");
          Serial.println(counter);
      }
      else if( (val == 1) && (detected == true ) ){
          counter==counter;
          delay(2000);
          detected = false;
          Serial.println(counter);
          Serial.print("Vacant=");
  
}

}

It is not a good idea to post your email address on this pub!ic forum. You are tnviting spam.

You have a count() function, but it is never called.

What is the problem with your code? Are there compile errors? If so, post the entire text of the error(s). Or describe what the code is actually doing and describe how that is different rhan what you want.

This must be a rather common assignment. I wonder how many others have asked here how to do it?

Paul