I think I know how to solve this but ut is not trivial.
You should start the ping ))) on all pins, preferably with direct port manipulation as
notoriou5 proposed.
but you should not use pulseIN for the receiving part as that is blocking code.
Instead you should use pinChangeInterrupts to get the timing of the 4 return signals.
if all 4 are set then one can convert timing to distance
in pseudocode
volatile uint32_t timing[4];
void loop()
{
// clear timing;
for (int i=0; i< 4; i++) timing[i] = 0UL;
initializePCI( <pins> ); // to be investigated
PORTC = pinMask;
delayMicroseconds(s);
// WAIT UNTIL READY
bool ready = false;
while (!ready)
{
ready = true;
for (int i=0; i<4; i++) ready = ready && timing[i] != 0);
}
for (int i=0; i<4; i++)
{
distance[i] = timing[i] /58;
Serial.println(distance[i]);
}
}
void PCinterrupt()
{
pin = ....somecode...
if (pin == HIGH) return; // wait for the LOW
timing[pin] = micros();
}
something like that.
read this thread - PinChangeInt library- To attach interrupts to multiple Arduino (Uno/Mega) pins - Exhibition / Gallery - Arduino Forum -
latest code - Google Code Archive - Long-term storage for Google Code Project Hosting. - 2.30 beta