IR sensor with Arduino for restaurant parking

Hi ,
I have problem in the code logic ,i did not find any solution.please give some suggestions.

my doubt is im using two IR sensor interface with arduino ,so when car is passing 1st sensor and 2nd sensor then i'm sending the data that car is passed ,that is fine but when ever car1 is passing 1st sensor and another car say ,car2 is in 2nd sensor than also flag is becoming 1 ,that is true but i dont want that.

how to code?, so that car should pass two sensors ,if car 1 is in sensor 1 and car 2 is in sensor 2 than flag should not be 1 .i hope u understand the problem.

please fing below code for understanding better.

thank you

RestorantCarSensor.ino (2.72 KB)

Please read this before posting a programming question and post your code here

that is not IR sensor ,i'm using ultrasonic sensor

please fing below code for understanding better.

Without some idea how the sensors are arranged, "fing"ing the code won't do any good.

If ultrasonic sensors really COULD be used for this purpose, why do you suppose that they so rarely are?

i'm unable find solution for this ,how two sensor use for this purpose ?

Forget about the sensors for now. How would two people do it if they were placed in the same positions as the sensors and could only see the same area as the sensors ?

Would they communicate with one another when a car arrived at the sensor ?
Would they communicate with one another when a car left the sensor ?
Would they note the time that a car arrived at the sensor position ?
Would they time how long the car could be seen at each sensor ?

but the sensor cannot communicate each other ,and they have placed 20 cm distance long.

but the sensor cannot communicate each other

They ARE able to communicate with the Arduino, though.

and they have placed 20 cm distance long.

We STILL haven't seen a picture.

20 centimeters is WAY too short a distance to measure cars moving.

it is not 20 cm ,sorry for that .it is 60 cm between two sensors.

these some conditions i wrote here,please find it out

Tell us how two people would do it and you may solve your problem, or prove that it is impossible

if i use only one sensor,any human passes to that can detect that sensor.so , i'm using two sensors for car parking system.

it is 60 cm between two sensors.

There appear to be about 60 centimeters between your ears, with nothing in between.

Post a picture, or quit wasting our time.

these are the conditions i should met while car is passing

So, the sensors are 60 centimeters apart, and two cars are supposed to be able to drive side by side between them.

Just how small ARE the cars? Obviously not big enough to hold people...

Have you tried moving one of your model cars past the sensors, to see just what values you get from each sensor?

  inches1 = microsecondsToInches(duration1);
  cm1 = microsecondsToCentimeters(duration1);

Have you not yet figured out which unit of measure you use in your country?

Why does your code deal with all three of your two sensors? The code that won't even compile.

cars not passing side by side but while car are moving ,that may occurs that car1 is on 1st sensor and car2 is on 2nd sensor.

here im using cm measure.

find the below code

RestorantCarSensor.ino (2.13 KB)

cars not passing side by side but while car are moving ,that may occurs that car1 is on 1st sensor and car2 is on 2nd sensor.

Post a picture showing the two sensors and two cars - however you are trying to measure whatever it is you are trying to measure.

actually i cannot post any picture because clients are in different city and my manager told me that,that is the issue they are facing currently .

actually i cannot post any picture because clients are in different city and my manager told me that,that is the issue they are facing currently .

So, you haven't a clue how the sensors are ACTUALLY positioned.

Can you say "Road trip!". I knew you could.

manisrinivas:
if i use only one sensor,any human passes to that can detect that sensor.so , i'm using two sensors for car parking system.

I think that you have missed the point of what I am asking.

Imagine that there are no sensors but there is a person sitting in the 2 places where they would be. Each of the two people are looking in the same direction as the sensors would be and can recognise whether there is currently a car in front of them or not. The two people can tell a third person what they can see.

Remember that they can only say
"I have just seen a car move into range"
"I have just seen a car move out of range"
"There is a car currently in range"
and
"There is no car currently in range"

With these pieces of information and/or combinations of them from the two people, how can the third person make the system work ?

here i have photo which i tried in my office place ,