Hello everyone!
This is my very first tutorial on LMR. I have spent a lot of time trying to connect a SRF05 to a Red Back Spider robot controller but in vain. But finally with the help of Dan M and ignoblegnome I got it working. Trust me for a begginer like me using a SRF05 on an arduino was a major achievement.
Okay now coming back to the tutorial, here is how the Spider controller looks like:
And this is a SRF05:
There are two ways of connecting a SRF05 to a board but I will show you the simplest one.
Turning the sensor back you will see a total of 10 pin holes , 5 on either sides:
Firstly I want you to solder 5 male headers to the bottom 5 holes of the SRF05 but be careful the solder of one pin should not touch another one!
Now comes the "connecting the wires to the SRF05 and the Spider" part.
First connecting the wires to the SRF05, here goes:
or as a schematic representation for any arduino including the Spider(dont look at this now it will only confuse you)
Now for the connecting the wires from the SRF05 to the Spider:
Now for the programing part using Arduino, you can just use the File>>Example>>Sensors>>Ping program where you have to just run the program without any changes if you have connected it to digitalpin 7 or if you have connected it to a different pin you can just change that 7 in the program to the pin which you have connected the yellow wire to.
Or you can use this program:
/* Arduino example for SRF05 Using a single pin for both trigger and echo. */int duration; // Stores duratiuon of pulse in
int distance; // Stores distance
int srfPin = 7; // Pin for SRF05void setup()
{
Serial.begin(9600);
}void loop()
{
pinMode(srfPin, OUTPUT);
digitalWrite(srfPin, LOW); // Make sure pin is low before sending a short high to trigger ranging
delayMicroseconds(2);
digitalWrite(srfPin, HIGH); // Send a short 10 microsecond high burst on pin to start ranging
delayMicroseconds(10);
digitalWrite(srfPin, LOW); // Send pin low again before waiting for pulse back in
pinMode(srfPin, INPUT);
duration = pulseIn(srfPin, 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);
delay(50); // Wait before looping to do it again
}
Even after going through this tutorial many times if you still aren’t getting it then ask me or any other LMRer.
ALL THE BEST!!!
CHEERS!!!
DTB