SRF08 solar rangemeter and arduino problem

Hello All,

I'm trying to run the code about the SRF08 ultrasonic range meter on Arduino. I found the code in Arduino's web page However, when i try to run this code i face to face an eror :

C:\Program Files\Arduino\arduino-0017\hardware\libraries\Sonar_srf08\Sonar_srf08.cpp: In member function 'void Sonar_srf08::setUnit(int, int, char)':

C:\Program Files\Arduino\arduino-0017\hardware\libraries\Sonar_srf08\Sonar_srf08.cpp:46: error: case label does not reduce to an integer constant

C:\Program Files\Arduino\arduino-0017\hardware\libraries\Sonar_srf08\Sonar_srf08.cpp:49: error: case label does not reduce to an integer constant

Do u have any idea about this?

Thank you...

Have you made any changes to the example sketch? The last argument for the setUnit command needs to be a character. The error messages indicate that it is not.

No i have not made any change. I have only opened the code and clicked the run.

Odd, the switch statement uses strings ("c" or "i") for case selectors (though the actual type is "char"), which would sort-of explains the error messages, but it compile OK under 0016, which doesn't.

but i have to use 0016 because 0017 does not work under vista

It compiles here on 0016 (Windoze 7)- though I agree it shouldn't.

If you change the "switch" in "setUnit" to use single quotes, it should compile.

[edit]Gone back at looking at the source - it looks like a work-in-progress. It's got:

//#define readInches 0x50
//#define readCentimeters 0x51

but then:

void Sonar_srf08::setUnit(int commandRegister, int address, char units){
  switch(units) {
        case "i": ;
  Sonar_srf08::sendCommand(commandRegister, address, 0x50);
        case "c": ;
  Sonar_srf08::sendCommand(commandRegister, address, 0x51);
  Serial.print("Invalid Units Entered...");


Unfortunately no! it did not change anything. The same eror remains.

I tried to compile under 0016, as u say it works. However, i tried to compile it in 0017 Under XP (previous eror code occurs in 0017 under vista) i faced to face another eror code such as 25: error: Sonar_srf08.h: No such file or directory In function 'void setup()': In function 'void loop()': :)

I'm about to be crazy :)