I'm beginning in Arduino I do not understand what the error means. Please tell me where I can find the resources to understand it and allow the code to compile.
#include <RCSwitch.h>
#include <Ultrasonic.h>
Ultrasonic ultrasonic(11,10);
RCSwitch mySwitch = RCSwitch();
int i;
void setup() {
mySwitch.enableTransmit(4);
}
void loop() {
i = ultrasonic.Ranging(CM);
mySwitch.send(i, 24);
delay(100);
}
Arduino: 1.8.7 (Windows 7), Board: "Arduino/Genuino Uno"
433mhz-lcd-water-level-transmitter:2:24: error: Ultrasonic.h: No such file or directory
compilation terminated.
exit status 1 Ultrasonic.h: No such file or directory
This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.
-
Did you install the library?gre_gor– gre_gor2018年10月06日 05:14:08 +00:00Commented Oct 6, 2018 at 5:14
-
I did add an ultrasonic library but have the same erroruser50090– user500902018年10月06日 11:04:32 +00:00Commented Oct 6, 2018 at 11:04
-
Thanks for all my problem is solved download ultrasonic code here arduinolibraries.info/libraries/ultrasonic i found another library ultrasonic solve my first problem(Ultrasonic.h: No such file or directory) but then have another error... it say(class Ultrasonic' has no member named 'Ranging').... in this time i changed some of my code and now working good my code after solve include include Ultrasonic ultrasonic(11,10); // (Trig PIN,Echo PIN) RCSwitch mySwitch = RCSwitch(); int i; void setup() { mySwitch.enableTransmit(4); } void loop() { Ultrasonic ultrasonic(11,10,3000); // (Triaras– aras2018年10月06日 13:23:58 +00:00Commented Oct 6, 2018 at 13:23
3 Answers 3
It means what it says:
Ultrasonic.h: No such file or directory
The file Ultrasonic.h
can't be found.
Anything in your code that starts #include...
is usually a library. These are third party pieces of software that you have to obtain and install into the relevant location (See Installing Additional Arduino Libraries).
Some libraries are bundled with the IDE, and some are available through the "library manager" in the IDE. However most aren't, and you will have to get used to finding those libraries and installing them.
The location you got your example code from will most likely link you to where to find the relevant libraries to get the code working.
This kind of error means that the Arduino IDE (assuming that is what your are using) did not find 'Ultrasonic.h' in a folder named 'libraries' within your Arduino sketch folder. (Some libraries are contained in other places within the IDE's executable, but putting your additional libraries in '.../libraries' keeps everything easy to find and maintain).
Go to File | Preferences
(in Windows or Linux) or Arduino | Preferences
(Mac). The top box in that dialog is the path to your sketch folder. That folder should contain one called 'libraries'.
The libraries folder should have a folder for each library, so in this case, there should be a folder named 'Ultrasonic', containing files 'Ultrasonic.h' and 'Ultrasonic.cpp'. There may be other items in there as well, perhaps an Examples folder, a 'keywords.txt' file (helps the IDE with syntax coloring), a text file with release notes, etc., but the important structure is
[path/to/your/sketch/folder]
libraries
Ultrasonic
Ultrasonic.h
Ultrasonic.cpp
someotherlibrary
someotherlibrary.h
etc.
-
the .h and .cpp of the library can be in src subfolder if 'new' library format is used2018年10月06日 13:21:07 +00:00Commented Oct 6, 2018 at 13:21
-
Indeed - thanks for pointing that out. The above should be taken as the minimum basic structure.JRobert– JRobert2018年10月06日 14:46:36 +00:00Commented Oct 6, 2018 at 14:46
i found another library ultrasonic solve my first problem(Ultrasonic.h: No such file or directory) but then have another error... it say(class Ultrasonic' has no member named 'Ranging').... in this time i changed some of my code and now working good
my code after solve
#include <RCSwitch.h>
#include <Ultrasonic.h>
Ultrasonic ultrasonic(11,10); // (Trig PIN,Echo PIN)
RCSwitch mySwitch = RCSwitch();
int i;
void setup() {
mySwitch.enableTransmit(4);
}
void loop() {
Ultrasonic ultrasonic(11,10,3000); // (Trig PIN,Echo PIN, Max.TimeOut in μsec )
mySwitch.send(3000 ,24);
delay(100);
}