And please, as requested in How to get the best out of this forum, don't use screen shots for code (or errors for that matter). The harder you make it for people to help you, the fewer people will be inclined to do so. Use the <CODE/> tool in the message toolbar.
#include<SR04.h>
int trig_Pin =12;
int echo_pin =11;
SR04 sensor = SR04(echo_pin,trig_pin);
long distance;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
distance= sensor.Distance():
Serial.println(distance);
delay(1000);
}
exit status 1
Error compiling for board Arduino Uno.
I'm sorry but you still haven't shown the error. And I don't know what library you're using. So I was unable to compile your sketch to see what the error was.
But if you had shown the error, I imagine it would have looked like this:
/home/me/Documents/sketchbook/Uno_R3/test/test.ino: In function 'void loop()':
/home/me/Documents/sketchbook/Uno_R3/test/test.ino:21:17: error: expected ';' before ':' token
distance= sensor.Distance():
^
And if that is indeed your error, the compiler is telling you exactly what you did wrong. Putting a little effort into reading the error messages goes a long way.
Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.
Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.
Repeated duplicate posting could result in a temporary or permanent ban from the forum.
Could you take a few moments to Learn How To Use The Forum
It will help you get the best out of the forum in the future.
Arduino: 1.8.1 (Windows 10), Board: "Arduino Uno"
avr-g++: error: C:\Users\menaa\OneDrive\?????????\Arduino\libraries\HC-SR04\SR04.cpp: Invalid argument
avr-g++: warning: '-x c++' after last input file has no effect
avr-g++: fatal error: no input files
compilation terminated.
exit status 1
Error compiling for board Arduino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
hi . i tried change location and found this error massage appear
Arduino: 1.8.1 (Windows 10), Board: "Arduino Uno"
In file included from C:\Users\menaa\Downloads\ardino files\sketch_feb03a\sketch_feb03a.ino:2:0:
C:\Users\menaa\Downloads\ardino files\libraries\DHT_sensor_library/DHT_U.h:36:10: fatal error: Adafruit_Sensor.h: No such file or directory
#include <Adafruit_Sensor.h>
^~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Arduino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
i dont understand that Adafruit_Sensor.h . i didnt use that in my code
Hi @menna112. Just as you use libraries in your sketch code, libraries may use other libraries. When you are using one of the libraries that does this, it is necessary to install the other libraries on which the library depends in addition to the library you are using directly in your sketch.
The "DHT sensor library" library has a dependency on the "Adafruit Unified Sensor" library (which contains the Adafruit_Sensor.h file). You don't have the "Adafruit Unified Sensor" library installed, so the compilation fails with this "No such file or directory" error.
You can solve it by installing the missing library.
I'll provide instructions you can follow to do that:
Select Sketch > Include Library > Manage Libraries... from the Arduino IDE menus.
The "Library Manager" dialog will open.
Wait for the update to finish, as indicated by the progress bar at the bottom of the "Library Manager" dialog.
Type Adafruit Unified Sensor in the "Filter your search..." field.
Press the Enter key.
Scroll down through the list of libraries until you see the "Adafruit Unified Sensor" entry. Click on it.
A menu and button will appear at the bottom of the entry.
Click the "Install" button in the "Adafruit Unified Sensor" entry.
You may now get a dialog asking:
Would you like to install also all the missing dependencies?
If so, click the "Install all" button.
Wait for the installation to finish.
Click the "Close" button in the "Library Manager" dialog.
The "Library Manager" dialog will close.
Now try compiling or uploading your sketch again. Hopefully this time you won't have any errors and everything will work as expected.