hi hoping someone can help.
i'd like to incorporate a sonar sensor into one of my projects and had a srf08 laying about. I found this setup instruction in the playground Arduino Playground - SonarSrf08
however after downloading the library from that page and after trying to verify the code (also unchanged from that page) i got this error compiling message
/Applications/Arduino.app/Contents/Resources/Java/libraries/Sonar_srf08/Sonar_srf08.cpp:49: error: case label does not reduce to an integer constant
Sorry, I re-read the other thread, and I think I can see why you thought it was unresolved, but I think the OP must have had other issues with their sketch, but didn't follow them up (or post their sketch).
Hope it's working now.
well got I the code to work.... I think the sensor might be bust though... I cant get a distance reading off it, keeps returning a 0 inch reading... Ill try and have a look at it later....
Without an oscilloscope, no not really.
Unless 40kHz will annoy your cat/dog.
Does the SRF08 have an LED, and does it flash when you take a reading?
Could you post your code as it is now?
(please use the # button on the editor's toolbar)
It has a small led on the back that flashes,
the code I'm using to see if i can get it to work is
#include <Wire.h>
#include <Sonar_srf08.h>
Sonar_srf08 MySonar;
#define CommandRegister 0x00
int New_Address = 248; //0xF8
#define ResultRegister 0x02
int DEBUG = 1;
char unit = 'i'; // 'i' for inches , 'c' for centimeters
float sensorReading =0;
void setup()
{
MySonar.connect();
MySonar.changeAddress(CommandRegister, New_Address);
if (DEBUG){
Serial.begin(9600);
}
New_Address += 4;
//offset address not sure why this is but it works for this address
}
void loop()
{
// set units for reading out distance
MySonar.setUnit(CommandRegister, New_Address, unit);
//pause
delay(70);
// set register for reading
MySonar.setRegister(New_Address, ResultRegister);
// read data from result register
sensorReading = MySonar.readData(New_Address, 2);
//print out distance
Serial.print("Distance: ");
Serial.print(sensorReading);
Serial.print(" inches");
Serial.println();
//pause
delay(70);
}
as in the playground example.
I have wired up everything as in the diagram except for the 1.8 kOhm pullup resistor.
I don't have one so I did the best I could with what i have and I'm getting 1.84 kOhm through 3 resistors.
However I've been talking to the guy I got the sensor off and he reckons it should have a 4.7kOhm resistors which I tried, and again i dont have one so I'm getting 4.72kOhm trough 6 resistors this time
and I'm getting the same result.