'class Ultrasonic' has no member named 'Ranging'

I'm new to arduino programming. I'm working on a project of Ultrasonic Distance Meter Using Arduino Uno. I got the program is :

#include <Ultrasonic.h>
#include <LiquidCrystal.h>
//Setup connection with LCD and HC-SR04
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Ultrasonic ultrasonic(A0,A1);
void setup() {
//Lcd init
lcd.begin(16, 2); //16 rows, 2 columns
}
void loop() {
lcd.clear();
lcd.print(" Distance Meter "); // You can change this message.
lcd.setCursor(0, 1); //Change line...
lcd.print("Distance: ");
lcd.print(ultrasonic.Ranging(CM));
lcd.print("cm");
delay(1000); // 1sec delay
}

But when i try to verify it, it gives me following error :

D:\Desktop\F6QO2RSI5F7GFJL\sketch_feb25a\sketch_feb25a.ino: In function 'void loop()':
sketch_feb25a:15: error: 'class Ultrasonic' has no member named 'Ranging'
lcd.print(ultrasonic.Ranging(CM));
** ^**
exit status 1
'class Ultrasonic' has no member named 'Ranging'

Please someone tell me what is wrong with it...

You can't expect everyone to have used, or have installed, the library Ultrasonic.h so best post a link to that.

(edit: I did a search and downloaded one, but the IDE library manager told me it wasn't a valid library. So back to you to provide link to a known-good one.)

".ranging" would be more likely and conventional.

old comments

The new Arduino 1.0 does not compile the Ultrasonic library because ultrasonic.h has #include “WProgram.h” and the WProgram.h is removed from version 1.0 – - see the forum I think deleting WProgram.h was a bad idea - #6 by pjrc - IDE 1.x - Arduino Forum

Possibly the library is outdated.

According to another comment a modified library are available at GitHub - hemalchevli/ultrasonic-library: Arduino Library to use with the ultrasonic sensor HC-SR04 but still it it more than 3 years old. Many changes in Arduino IDE might have broken it again.

No problem here with the Github version and IDE 1.8.1.

Is it possible that you have another Ultrasonic.h lying around somewhere?

Guys, thank you for your response, but i am really new to this :frowning: . I dont even understand what you are saying. and i think I do have ultrasonic.h library installed. Check the attachment.

manor_royal:
You can't expect everyone to have used, or have installed, the library Ultrasonic.h so best post a link to that.

(edit: I did a search and downloaded one, but the IDE library manager told me it wasn't a valid library. So back to you to provide link to a known-good one.)

this is the one that i've installed

GitHub - ErickSimoes/Ultrasonic: Minimalist library for Ultrasonic Module HC-SR04, PING))) and Seeed SEN136B5B to Arduino

class Ultrasonic {
  public:
    Ultrasonic(uint8_t trigPin, uint8_t echoPin);
    int distanceRead(uint8_t und);
    int distanceRead();

  private:
    uint8_t trig;
    uint8_t echo;
    int timing();
};

The compiler was right - no "Ranging".
Imagine that.

You might have a very old, incompatible, Ultrasonic library installed.
Github version is confirmed working. Download and replace your current files.
I found another Ultrasonic library in Arduino library manager.
ultrasonic.Ranging(CM) corresponds to the first, but as you get an error on it, it might be you are using a function from another library than you have installed.
Find ultrasonic.h and open it with notepad and copy it all here.
In windows you will most likely find it in C:\Users\Your name\Documents\Arduino\libraries\Ultrasonic\src

You should have a look at the readme for the library you are using.

oqibidipo:
No problem here with the Github version and IDE 1.8.1.

Is it possible that you have another Ultrasonic.h lying around somewhere?

can you send me your .ino file please?
ktnslv27@gmail.com

Gabriel_swe:
You might have a very old, incompatible, Ultrasonic library installed.
Github version is confirmed working. Download and replace your current files.
I found another Ultrasonic library in Arduino library manager.
ultrasonic.Ranging(CM) corresponds to the first, but as you get an error on it, it might be you are using a function from another library than you have installed.
Find ultrasonic.h and open it with notepad and copy it all here.
In windows you will most likely find it in C:\Users\Your name\Documents\Arduino\libraries\Ultrasonic\src

You should have a look at the readme for the library you are using.
Ultrasonic/README.md at master · ErickSimoes/Ultrasonic · GitHub

i really don't understand. :confused:

ketan2702:
can you send me your .ino file please?
ktnslv27@gmail.com

It will not work as he tried the library you you used code for, which isn't working for you as you have another library installed.

BUT, with your library comes an example you can look at. I would connect sensor to digital pins as in the example. File > Examples > Ultrasonic > UltrasonicSimple
Libraries usually comes with examples if you look for them.

ketan2702:
i really don't understand. :confused:

Two different libraries with same name. You have one library installed but used the syntax from the other. That doesn't work as every library has its own syntax.
I would say it is quite rare a library is released with the same name as an already existing name, but in this case it exists.

To see the manual for your installed Ultrasonic library, see this
readme file

Once again thanks for your quick response. :slight_smile:
This is the website from where I got the ides and program as well.

They've provided a library there. I tried installing it and compiling but still i get the same error.

Can someone please suggest what changes do I've to do in the program..!! :cold_sweat:

Thank you guys for your support. I've figured it out that the library i was using was having ultrasonick.h spelling and in program there was ultrasonic.h.

So imade some changes and instead of ultrasonic.ranging i've declared a variable and then stored the distance in it using ultrasonick.distanceRead().

Now the program is been verified and successfully written on board.

Once again thank you for your support. :slight_smile: