Problem with Ultrasound Sensor
I am working on a current project but seem to be having a ridiculous amount of difficulty implementing an SRF02 Ultrasound sensor. I am using it in serial mode and communicating with an Arduino Duemilanove. The problem is not in the wiring as I triple checked that.
The adruino is supposed to send 2 bytes to the SRF02 [ address, command ] and then receive 2 bytes in response giving the distance measured by the sensor.
In my setup the SRF02 blinks so I can see that it is receiving the command and doing a ranging operation. However for some reason I get no response from it. The problem is somewhere in the code and I could really use some help. I bet its something simple and silly.... Bellow is my code and the serial monitor output. Please tell me where I am wrong. My version of Arduino IDE is 17 but that shouldn't be a problem.
Documentation for SRF02
#define srfAdrs 00 // Address of the SRF02
#define rangeCM 84 // Byte for start of ranging data
Serial.write(byte(srfAdrs)); // send address byte
Serial.write(byte(rangeCM)); //send command byte
if (Serial.available() > 0)
incomingByte = Serial.read(); // read serial response
Serial.print(incomingByte); // write distance measured
Serial.flush(); // clear buffer
Serial Monitor Output: