Using New Ping library and TONE together
hello,
i thought throw code varying tone distance returned hc-sr04 ultrasonic module.
i thought mapping returned distance using newping library in conjunction tone. compilation error message:
arduino: 1.0.6 (windows 7), board: "arduino mega 2560 or mega adk"
core.a(tone.cpp.o): in function `__vector_13':
c:\program files\arduino\hardware\arduino\cores\arduino/tone.cpp:535: multiple definition of `__vector_13'
newping\newping.cpp.o:c:\documents\arduino\libraries\newping/newping.cpp:214: first defined here
c:/program files/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: disabling relaxation: not work multiple definitions
i'm using mega-2560. there fundamental problem of using pwm's together? can post code if wants look?
thanks.
i thought throw code varying tone distance returned hc-sr04 ultrasonic module.
i thought mapping returned distance using newping library in conjunction tone. compilation error message:
arduino: 1.0.6 (windows 7), board: "arduino mega 2560 or mega adk"
core.a(tone.cpp.o): in function `__vector_13':
c:\program files\arduino\hardware\arduino\cores\arduino/tone.cpp:535: multiple definition of `__vector_13'
newping\newping.cpp.o:c:\documents\arduino\libraries\newping/newping.cpp:214: first defined here
c:/program files/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: disabling relaxation: not work multiple definitions
i'm using mega-2560. there fundamental problem of using pwm's together? can post code if wants look?
thanks.
code is:
#include <newping.h>
#define trigger_pin 12 // arduino pin tied trigger pin on ultrasonic sensor.
#define echo_pin 11 // arduino pin tied echo pin on ultrasonic sensor.
#define max_distance 300 // maximum distance want ping (cm).
newping sonar(trigger_pin, echo_pin, max_distance); // newping setup of pins , max distance.
void setup() {
serial.begin(115200); // open serial monitor @ 115200 baud see ping results.
}
void loop()
{
delay(50); // wait 50ms between pings.
unsigned int = sonar.ping_median(10); //multiple readings returned in microseconds.
serial.print("ping: ");
unsigned int dist = (us / us_roundtrip_cm); // convert ping time cm , print result.
serial.print(dist); //print distance.
serial.println("cm");
// map distance range (in case, 1cm 300cm ultrasonic sensor.
// output pitch range (120 - 1500hz)
unsigned int thispitch = map(dist, 1, 300, 120, 1500); //map distance.
tone(9, thispitch, 10); // play pitch:
delay(1); // delay in between reads stability
}
#include <newping.h>
#define trigger_pin 12 // arduino pin tied trigger pin on ultrasonic sensor.
#define echo_pin 11 // arduino pin tied echo pin on ultrasonic sensor.
#define max_distance 300 // maximum distance want ping (cm).
newping sonar(trigger_pin, echo_pin, max_distance); // newping setup of pins , max distance.
void setup() {
serial.begin(115200); // open serial monitor @ 115200 baud see ping results.
}
void loop()
{
delay(50); // wait 50ms between pings.
unsigned int = sonar.ping_median(10); //multiple readings returned in microseconds.
serial.print("ping: ");
unsigned int dist = (us / us_roundtrip_cm); // convert ping time cm , print result.
serial.print(dist); //print distance.
serial.println("cm");
// map distance range (in case, 1cm 300cm ultrasonic sensor.
// output pitch range (120 - 1500hz)
unsigned int thispitch = map(dist, 1, 300, 120, 1500); //map distance.
tone(9, thispitch, 10); // play pitch:
delay(1); // delay in between reads stability
}
Arduino Forum > Using Arduino > Programming Questions > Using New Ping library and TONE together
arduino
Comments
Post a Comment