user15032: I am trying to get values for two ping sensors, but am not getting any returns, can someone help me edit my code?
Code
void setup()
{
  Serial.begin(9600); 
  pingRange(2);
  pingRange(3);
}

void loop(){
}

  long pingRange (int pingPin)

{
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);
  pinMode(pingPin, INPUT);
  return microsecondsToCentimeters(pulseIn(pingPin, HIGH));
}

long microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}


user4143: There's one part of your code conspicuous by its absence:
pingRange(2);
pingRange(3);

You're calling the functions, but you're not doing anything with the returned value.  I think you meant to print that value to the serial interface...
Serial.println(pingRange(2));
Serial.println(pingRange(3));


15032: <p>I am trying to get values for two ping sensors, but am not getting any returns, can someone help me edit my code?</p>

<h1>Code</h1>

<pre><code>void setup()
{
  Serial.begin(9600); 
  pingRange(2);
  pingRange(3);
}

void loop(){
}

  long pingRange (int pingPin)

{
  pinMode(pingPin, OUTPUT);
  digitalWrite(pingPin, LOW);
  delayMicroseconds(2);
  digitalWrite(pingPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(pingPin, LOW);
  pinMode(pingPin, INPUT);
  return microsecondsToCentimeters(pulseIn(pingPin, HIGH));
}

long microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}
</code></pre>
 4143: <p>There's one part of your code conspicuous by its absence:</p>

<pre><code>pingRange(2);
pingRange(3);
</code></pre>

<p>You're calling the functions, but you're not doing anything with the returned value.  I think you meant to print that value to the serial interface...</p>

<pre><code>Serial.println(pingRange(2));
Serial.println(pingRange(3));
</code></pre>
