Tanmay_Karmakar New Member Jul 22, 2020 #1 Using NewPing library for a project but stuck cause I can't use tone function in that. "Error: Id returned 1 exit status......" Why is it happening? What is the solution? Attachments Screenshot_20200722-164430.jpg 281.9 KB · Views: 420
Using NewPing library for a project but stuck cause I can't use tone function in that. "Error: Id returned 1 exit status......" Why is it happening? What is the solution?
P Pommie Well-Known Member Most Helpful Member Jul 22, 2020 #2 Can you post ALL your code, not just snippets. Mike. Edit, don't post a picture of your code, post the text between code tags. Last edited: Jul 22, 2020
Can you post ALL your code, not just snippets. Mike. Edit, don't post a picture of your code, post the text between code tags.
U upand_at_them Active Member Jul 22, 2020 #3 You'll find much more Arduino help on the official Arduino forums: forum.arduino.cc
Tanmay_Karmakar New Member Jul 22, 2020 #4 Pommie said: Can you post ALL your code, not just snippets. Mike. Edit, don't post a picture of your code, post the text between code tags. Click to expand... Ok.. here it is.. without just the tone function the program compiles fine.. Code: #include "NewPing.h" #define echoPin 7 #define trigPin 6 #define buzzPin 8 unsigned int dly=300; NewPing distance(trigPin, echoPin, 500); void setup() { pinMode(buzzPin, OUTPUT); Serial.begin(115200); } void loop() { float cm=distance.convert_cm(distance.ping_median()); Serial.println(" Subject is "); Serial.print(cm); Serial.print(" cm away"); noTone(buzzPin); while(cm<300) { unsigned int gap=(dly-cm)*50; tone(buzzPin, gap, 400); } }
Pommie said: Can you post ALL your code, not just snippets. Mike. Edit, don't post a picture of your code, post the text between code tags. Click to expand... Ok.. here it is.. without just the tone function the program compiles fine.. Code: #include "NewPing.h" #define echoPin 7 #define trigPin 6 #define buzzPin 8 unsigned int dly=300; NewPing distance(trigPin, echoPin, 500); void setup() { pinMode(buzzPin, OUTPUT); Serial.begin(115200); } void loop() { float cm=distance.convert_cm(distance.ping_median()); Serial.println(" Subject is "); Serial.print(cm); Serial.print(" cm away"); noTone(buzzPin); while(cm<300) { unsigned int gap=(dly-cm)*50; tone(buzzPin, gap, 400); } }
P Pommie Well-Known Member Most Helpful Member Jul 22, 2020 #5 If the program doesn't compile, what's the error message? Mike.
Tanmay_Karmakar New Member Jul 23, 2020 #6 Pommie said: If the program doesn't compile, what's the error message? Mike. Click to expand... "NewPing.cpp:361: first defined here collect2: error: Id returned 1 exit status Return code is not 0" Attachments Screenshot_20200722-164430_1.jpg 36.3 KB · Views: 370
Pommie said: If the program doesn't compile, what's the error message? Mike. Click to expand... "NewPing.cpp:361: first defined here collect2: error: Id returned 1 exit status Return code is not 0"
Ian Rogers User Extraordinaire Forum Supporter Most Helpful Member Jul 23, 2020 #7 tone ( pin, frequency, duration); It specifically says unsigned int, you are passing a float.. cast it to see if it fixes tone(buzzpin, round(gap), 400); or.. tone(buzzpin, (int)gap, 400);
tone ( pin, frequency, duration); It specifically says unsigned int, you are passing a float.. cast it to see if it fixes tone(buzzpin, round(gap), 400); or.. tone(buzzpin, (int)gap, 400);
Tanmay_Karmakar New Member Jul 23, 2020 #8 Ian Rogers said: tone ( pin, frequency, duration); It specifically says unsigned int, you are passing a float.. cast it to see if it fixes tone(buzzpin, round(gap), 400); or.. tone(buzzpin, (int)gap, 400); Click to expand... Thanks.. it seems to be a silly mistake... But still the problem remains..
Ian Rogers said: tone ( pin, frequency, duration); It specifically says unsigned int, you are passing a float.. cast it to see if it fixes tone(buzzpin, round(gap), 400); or.. tone(buzzpin, (int)gap, 400); Click to expand... Thanks.. it seems to be a silly mistake... But still the problem remains..
Tanmay_Karmakar New Member Jul 23, 2020 #9 I've found the culprit, it's that they both use the same interrupt "vector__7". That was in the error msg, anyhow I didn't saw that earlier.
I've found the culprit, it's that they both use the same interrupt "vector__7". That was in the error msg, anyhow I didn't saw that earlier.
P Pommie Well-Known Member Most Helpful Member Jul 23, 2020 #10 Where does it mention that in the error message? Mike.
Tanmay_Karmakar New Member Jul 23, 2020 #11 Pommie said: Where does it mention that in the error message? Mike. Click to expand... Above the last error msg... Sorry I can't copy paste the error msg from ArduinoDroid. Attachments Screenshot_20200724-104047_1.jpg 40.7 KB · Views: 348
Pommie said: Where does it mention that in the error message? Mike. Click to expand... Above the last error msg... Sorry I can't copy paste the error msg from ArduinoDroid.