Let's Make Robots!

Using SRF005 with arduino

Can anyone please show me how to program my arduino duemilanove  to use the SRF005 ultrasound? 

thanks in advance : )

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Here's the code I use to get distance in cm. It's essentially the same as the Ping sensor.  I used the single pin on the SRF05 for both functions:

long getDistance() {
  long duration;
  pinMode( PING_PIN, OUTPUT );
  digitalWrite( PING_PIN, LOW );
  delayMicroseconds( 2 );
  digitalWrite( PING_PIN, HIGH );
  delayMicroseconds( 5 );
  digitalWrite( PING_PIN, LOW );

  pinMode( PING_PIN, INPUT );
  duration = pulseIn( PING_PIN, HIGH );

  long d = ( duration / 29 / 2 );
  Serial.println( d );
  return d;