tpasaro5:
Time will start when the transmission from arduino 1 will trigger. Arduino 2 will receive it and immediately send a transmission back to arduino 1. Once arduino 1 receives the transmission by arduino 2 the time will stop.
That I have figured out already.
I would love to hear how you plan to accomplish this if Arduino 1 and 2 are not connected by wires or radios. Do tell, please.
For the future...some great reading on the HC-SR04: HC-SR04 | David Pilling Potentially useful information for the OP and others with similar aspirations starts at "Thinking that the comparator with threshold input was hiding what was actually going on..." Could allow an Arduino to monitor an HC-SR04 and identify when the sensor has received an ultrasonic pulse (without needing to trigger it and wait for an echo or incoming pulse from an unconnected transmitter).
As soon as you trigger the HC-SR04, it's waiting for a sound signal to come in - it doesn't know it's from another sensor. So all you have to do is trigger them both at the same time.
jremington:
Indeed! And to do that, there has to be some connection between them. But the OP is a long way from understanding this.
Yeah no triggering them at the same time will not work for my application. Is there any other way? Maybe with a different ultrasonic sensor?
The IR sensors I coded up worked well because I was able to use the receiver module as an output. The only problem was that it was waaaaay to fast for the arduino to process.
I guess what i'm saying is that I need an ultrasonic receiver that can be coded as an output. Does this exist?
tpasaro5:
...triggering them at the same time will not work for my application. Is there any other way?
Why can't you connect them with wires, radio, or IR? Maybe you should explain more about your application and the reasons for the limitations you seem to think exist.
There may be a way to make an HC-SR04 "receive" without a connection to the transmitter...but if it is feasible without a connection, it is only for someone with very good electronics skills (that is, it is more than just a "coding" problem). See the first link at the bottom of post #20.
You mentioned you made an IR link. You can use that same link to send a signal to the second Arduino, telling it to trigger its ultrasonic receiver to start listening.
Of course there is a short delay in sending the IR signal from the master, as the slave has to receive and process it. But you know that time so can easily compensate for it.
Now as IR may be pretty directional, you could achieve the same with Bluetooth or 433 MHz wireless links which are more omnidirectional.