Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature currently requires accessing the site using the built-in Safari browser.
Ok.. here it is.. without just the tone function the program compiles fine..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.
#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);
}
}
"NewPing.cpp:361: first defined here collect2: error: Id returned 1 exit statusIf the program doesn't compile, what's the error message?
Mike.
Thanks.. it seems to be a silly mistake... But still the problem remains..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);
Above the last error msg...Where does it mention that in the error message?
Mike.