SRF05 (ultrasonic sensor) and arduino
In this tutorial we are going to learn how to use a SRF05 ultrasonic sensor with arduino in a mode which uses only one digital output pin on your microcontroller.
While making the connections make sure you are holding the srf05 as shown in the below figure.
If you are connecting as per below figure then the LED on the srf05 should be up.The Holes/pins next to the LEDs are not supposed to be used.They are only used at the time of manufacturing for programming.
As we are using SRF05 in a mode which is same as for PING(((( sensor,you can use the example code given for PING((( sensor in arduino IDE
Go to FILE > EXAMPLES > SENSORS > PING
Or you can use this code
// Community of Robots//
//SRF05 sample code//
int duration; //Stores duration of pulse in
int distance; // Stores distance
int sensorpin = 7; // Pin for SRF05
digitalWrite(sensorpin, LOW); // Make sure pin is low before sending a short high to trigger ranging
digitalWrite(sensorpin, HIGH); // Send a short 10 microsecond high burst on pin to start ranging
digitalWrite(sensorpin, LOW); // Send pin low again before waiting for pulse back in
duration = pulseIn(sensorpin, HIGH); // Reads echo pulse in from SRF05 in micro seconds
distance = duration/58; // Dividing this by 58 gives us a distance in cm
Serial.println(distance); // Wait before looping to do it again
If you have made the connections properly then you will see the LED on back of SRF05 blinking.
After this open the serial monitor in arduino IDE and take your hand infront of SRF05 and you will see the changes in readings/distances.