user11974: I got this question from my teacher the other day and I can't figure it out:

If you have two sensors from two different outputs but want them to go into one input, what do you need, and how can you read the input?


In short, the project includes an Arduino Uno with two ultrasonic sensors.

user6740: This solution only actually uses one pin, but only works with simple things like push buttons (which are either open, or closed).
Connect a (different) resistor in series (end-to-end) with each switch. Connect the loose end of each resistor together to +5V. Connect the loose end of those two switches together, then via another resistor to ground. Where the two switches meet, connect them to an analog pin on your Arduino.
For example, you might use a 20k resistor with button A, and a 10k resistor with button B, and a 10k resistor connected to ground. They should be pretty close to the same value, and at least 1k each.
Use the ReadAnalogVoltage sketch to measure the voltage with different combinations of button presses (no button pressed, A, B, A+B), then, in your final sketch, you can compare the value read with the values in this table - pick the closest one, because actual readings may vary slightly. For the resistors above, you should get about: (no button = 0v; A=1.7v, B=2.5v, both 3v). Sort these numerically (which in this case they already are), and work out the values exactly between each pair (up to 0.85 is closest to 0=> no button; else up to 2.1=> button A; else up to 2.75 is closest to B; otherwise, both are pressed.
The circuit described looks like this: 

The wire leading off to the right goes to the analog pin on the Arduino. Switch A is on the left.
The results can be used either in a table, with a loop, or in an if/else if statement (I used this technique on a 12-key keypad, so the list was a lot longer).
Read up about voltage dividers https://learn.sparkfun.com/tutorials/voltage-dividers and, for both buttons being pressed at the same time, resistors in parallel https://learn.sparkfun.com/tutorials/series-and-parallel-circuits

user9815: 
If you have two sensors from two different outputs but want them to go
  into one input, what do you need, and how can you read the input?

If you want your teacher lose his mind answer his question with this:
What I need? :)

A wire


The solution is to use one trig for both ultrasonic sensor and two echos.
or one echo and two triggers.
ultrasonic sensor sends the pulse > pulse back > now echo pin is connected to second sensors trig > the Second Ultrasonic sensor sends the pulse then starts listening. When the second ultrasonic echo back, it sends to other Arduino pin, reverse it if you want it on one input pin :)
#define trigPin 6
#define echoPin 4
#define echoPin2 7

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

void loop() {
  long duration, distance, distance2;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(20);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  duration = duration + pulseIn(echoPin2, HIGH);
  distance2 = (duration/2) / 29.1;
  if (distance >= 200 || distance <= 0){ 
    Serial.println("Out of range");
  }
  else {
    Serial.print(distance);
    Serial.println("cm");
       Serial.print(distance2);
    Serial.println(" cm");
        Serial.println("HHH");
  }
  delay(500);
}

that's it.

user21426: I ran into the same question, except I wanted to put 8 of the HC-SR04 sensors on pro-mini.
I used an I2C pin expander for the triggers, and an octal OR/NOR chip to multiplex the return.
Library, examples and pictures
https://github.com/arielnh56/SonarI2C
http://redhunter.com/blog/2016/04/28/sonari2c-multiple-hc-sr04-sensors-on-arduino-i2c/

user26717: The OP does not specify whether the focus is on hardware or software.
So I will presume that what the professor might looking for is a solution using minimal circuitry; as close to the diagram as possible.  Thus, the solution would be implemented in software.
Given all that, I'd propose that the trigger signal be sent out on sensor 1, and the reflection measured at the receiving pin.  
It is time-gated (the time for the sensor to react to an object at maximum range).  If detected, then set a variable saving the distance measured on sensor 1.
Then the same could be sent from the second sensor's trigger pin.  And if there is a reflection within the time-gate then that can be recorded in another variable.  
It would require creating two instances of the ultrasonic sensor, and they would just happen to share the same receive pulse pin.  

user4143: There are two basic solutions to your problem, an active one and a passive one, and which is best (or will even work) depends on the rest of your setup.
The active solution requires a device called a multiplexer.  This is basically a switch and it selects one of its inputs to route through to its output, so it can be used to connect your input pin to the output of one of the sensors.  It requires an extra IO pin, though, so is pretty pointless as you could just use that IO pin as an input from the second sensor.  It does mean, though, that both sensors can be active at once and you just select one to read the output from.
The passive solution is called open drain or open collector (if you are using TTL not CMOS terminology).  This means you convert each of the outputs of the sensors into a switch using a transistor (NPN BJT or N-Channel MOSFET) to connect your input pin to ground.  When then transistors are off the input pin is pulled up through a pullup resistor (could be internal or external to the IO pin).  When one sensor's output activates it turns on the transistor which then pulls the input pin low.  This means that you can only have one sensor active at a time, so they have to be triggered by separate output pins.

Open Drain is how things like I2C support multiple devices on the same bus without any voltage conflicts.

11974: <p>I got this question from my teacher the other day and I can't figure it out:</p>

<blockquote>
  <p>If you have two sensors from two different outputs but want them to go into one input, what do you need, and how can you read the input?</p>
</blockquote>

<p><a href="https://i.stack.imgur.com/Xb7N2.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Xb7N2.jpg" alt="enter image description here"></a></p>

<p>In short, the project includes an Arduino Uno with two ultrasonic sensors.</p>
 6740: <p>This solution only actually uses one pin, but only works with simple things like push buttons (which are either open, or closed).</p>

<p>Connect a (different) resistor in series (end-to-end) with each switch. Connect the loose end of each resistor together to +5V. Connect the loose end of those two switches together, then via another resistor to ground. Where the two switches meet, connect them to an analog pin on your Arduino.</p>

<p>For example, you might use a 20k resistor with button A, and a 10k resistor with button B, and a 10k resistor connected to ground. They should be pretty close to the same value, and at least 1k each.</p>

<p>Use the ReadAnalogVoltage sketch to measure the voltage with different combinations of button presses (no button pressed, A, B, A+B), then, in your final sketch, you can compare the value read with the values in this table - pick the closest one, because actual readings may vary slightly. For the resistors above, you should get about: (no button = 0v; A=1.7v, B=2.5v, both 3v). Sort these numerically (which in this case they already are), and work out the values exactly between each pair (up to 0.85 is closest to 0=> no button; else up to 2.1=> button A; else up to 2.75 is closest to B; otherwise, both are pressed.</p>

<p>The circuit described looks like this: </p>

<p><a href="https://i.stack.imgur.com/LjsPo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LjsPo.png" alt="Switch circuit"></a></p>

<p>The wire leading off to the right goes to the analog pin on the Arduino. Switch A is on the left.</p>

<p>The results can be used either in a table, with a loop, or in an if/else if statement (I used this technique on a 12-key keypad, so the list was a lot longer).</p>

<p>Read up about voltage dividers <a href="https://learn.sparkfun.com/tutorials/voltage-dividers" rel="nofollow noreferrer">https://learn.sparkfun.com/tutorials/voltage-dividers</a> and, for both buttons being pressed at the same time, resistors in parallel <a href="https://learn.sparkfun.com/tutorials/series-and-parallel-circuits" rel="nofollow noreferrer">https://learn.sparkfun.com/tutorials/series-and-parallel-circuits</a></p>
 9815: <blockquote>
  <p>If you have two sensors from two different outputs but want them to go
  into one input, what do you need, and how can you read the input?</p>
</blockquote>

<p>If you want your teacher lose his mind answer his question with this:</p>

<p>What I need? :)</p>

<ul>
<li>A wire</li>
</ul>

<p><a href="https://i.stack.imgur.com/QhnyU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QhnyU.jpg" alt="enter image description here"></a></p>

<p>The solution is to use one trig for both ultrasonic sensor and two echos.</p>

<p>or one echo and two triggers.</p>

<p>ultrasonic sensor sends the pulse > pulse back > now echo pin is connected to second sensors trig > the Second Ultrasonic sensor sends the pulse then starts listening. When the second ultrasonic echo back, it sends to other Arduino pin, reverse it if you want it on one input pin :)</p>

<pre><code>#define trigPin 6
#define echoPin 4
#define echoPin2 7

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

void loop() {
  long duration, distance, distance2;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(20);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  duration = duration + pulseIn(echoPin2, HIGH);
  distance2 = (duration/2) / 29.1;
  if (distance &gt;= 200 || distance &lt;= 0){ 
    Serial.println("Out of range");
  }
  else {
    Serial.print(distance);
    Serial.println("cm");
       Serial.print(distance2);
    Serial.println(" cm");
        Serial.println("HHH");
  }
  delay(500);
}
</code></pre>

<p>that's it.</p>
 21426: <p>I ran into the same question, except I wanted to put 8 of the HC-SR04 sensors on pro-mini.</p>

<p>I used an I2C pin expander for the triggers, and an octal OR/NOR chip to multiplex the return.</p>

<p>Library, examples and pictures</p>

<p><a href="https://github.com/arielnh56/SonarI2C" rel="nofollow">https://github.com/arielnh56/SonarI2C</a>
<a href="http://redhunter.com/blog/2016/04/28/sonari2c-multiple-hc-sr04-sensors-on-arduino-i2c/" rel="nofollow">http://redhunter.com/blog/2016/04/28/sonari2c-multiple-hc-sr04-sensors-on-arduino-i2c/</a></p>
 26717: <p>The OP does not specify whether the focus is on hardware or software.</p>

<p>So I will presume that what the professor might looking for is a solution using minimal circuitry; as close to the diagram as possible.  Thus, the solution would be implemented in software.</p>

<p>Given all that, I'd propose that the trigger signal be sent out on sensor 1, and the reflection measured at the receiving pin.  </p>

<p>It is time-gated (the time for the sensor to react to an object at maximum range).  If detected, then set a variable saving the distance measured on sensor 1.</p>

<p>Then the same could be sent from the second sensor's trigger pin.  And if there is a reflection within the time-gate then that can be recorded in another variable.  </p>

<p>It would require creating two instances of the ultrasonic sensor, and they would just happen to share the same receive pulse pin.  </p>
 4143: <p>There are two basic solutions to your problem, an active one and a passive one, and which is best (or will even work) depends on the rest of your setup.</p>

<p>The active solution requires a device called a <em>multiplexer</em>.  This is basically a switch and it selects one of its inputs to route through to its output, so it can be used to connect your input pin to the output of one of the sensors.  It requires an extra IO pin, though, so is pretty pointless as you could just use that IO pin as an input from the second sensor.  It does mean, though, that both sensors can be active at once and you just select one to read the output from.</p>

<p>The passive solution is called <em>open drain</em> or <em>open collector</em> (if you are using TTL not CMOS terminology).  This means you convert each of the outputs of the sensors into a switch using a transistor (NPN BJT or N-Channel MOSFET) to connect your input pin to ground.  When then transistors are off the input pin is pulled up through a pullup resistor (could be internal or external to the IO pin).  When one sensor's output activates it turns on the transistor which then pulls the input pin low.  This means that you can only have one sensor active at a time, so they have to be triggered by separate output pins.</p>

<p><a href="https://i.stack.imgur.com/z7pDQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z7pDQ.png" alt="enter image description here"></a></p>

<p>Open Drain is how things like I2C support multiple devices on the same bus without any voltage conflicts.</p>
