Let's Make Robots!

How to connect the SRF05 to Arduino Decimialia?

How do I do this? Ive seen things for the PING but not the SRF05

Comment viewing options

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

I use the SRF05 in mode 1 with an Arduino in my Little Drum Machine. Here's the code I use for that:

#define SONAR_TRIGGER_PIN              2
#define SONAR_ECHO_PIN                 3

unsigned int measure_distance()
   // send the sensor a 10 microsecond pulse:
   digitalWrite(SONAR_TRIGGER_PIN, HIGH);
   digitalWrite(SONAR_TRIGGER_PIN, LOW);

   // wait for the pulse to return. The pulse
   // goes from low to HIGH to low, so we specify
   // that we want a HIGH-going pulse below:
   unsigned long pulse_length = pulseIn(SONAR_ECHO_PIN, HIGH);

   // can't send more than one pulse each 50 ms or
   // we could get interference

   // convert to inches and return
   return( (unsigned int) (pulse_length / 148) );

void setup()
   pinMode(SONAR_TRIGGER_PIN,          OUTPUT);
   pinMode(SONAR_ECHO_PIN,             INPUT);

void loop()
   unsigned int current_distance = measure_distance();


If you set the SRF05 into mode 2 (connect the mode to ground) it appears to operate the same as the Parallax Ping. See the reference to mode 2 at SRF05 tech page in comparison to the Ping data pdf.