user19608: I want to use two ultrasonic sensors for counting incoming cars to a garage. What I want is: When both sensors detect the object then the counter should increase.
Can anyone help me and give me an example? 

user15457: If you have two sensors, you use analogRead.
int sensor1 = A0;
int sensor2 = A1;
int distance = 50; // or whatever you want here
bool car_passing = false;

void setup(){
    int counter = 0;
}

void loop(){
    if(analogRead(sensor1) < distance && 
       analogRead(sensor2) < distance && 
       !car_passing)
    {
        car_passing = true;
        counter++; 
    }

    if(analogRead(sensor1) > distance){
        car_passing = false;
    }
}

To prevent the counter keep counting while the car is passing by, we need to make a boolean, so the counter does not wait for count again, before the car has passed.

19608: <p>I want to use two ultrasonic sensors for counting incoming cars to a garage. What I want is: When both sensors detect the object then the counter should increase.</p>

<p>Can anyone help me and give me an example? </p>
 15457: <p>If you have two sensors, you use analogRead.</p>

<pre class="lang-c prettyprint-override"><code>int sensor1 = A0;
int sensor2 = A1;
int distance = 50; // or whatever you want here
bool car_passing = false;

void setup(){
    int counter = 0;
}

void loop(){
    if(analogRead(sensor1) &lt; distance &amp;&amp; 
       analogRead(sensor2) &lt; distance &amp;&amp; 
       !car_passing)
    {
        car_passing = true;
        counter++; 
    }

    if(analogRead(sensor1) &gt; distance){
        car_passing = false;
    }
}
</code></pre>

<p>To prevent the counter keep counting while the car is passing by, we need to make a boolean, so the counter does not wait for count again, before the car has passed.</p>
