Hi,
I'm very new to Arduino, but already addicted.
I'm trying a very simple sketch to play a tone on a buzzer (piezo) with the tone() function, but I get an error every time I compile. Wouldn't have thought, that this is so complicated.
Here is the sketch:
int speakerPin = 7; //set the piezo-Pin
int f=440; //set the frequency
void setup(){
pinMode(speakerPin,OUTPUT); //optional, already in tone()-function
}
void loop(){
noTone(speakerPin); //kill previous signal
delay(500);
tone(speakerPin, f);
delay(500);
}
This is the error code:
Tone.cpp.o: In function `loop':
C:\Users\CHRIST~1\AppData\Local\Temp\build6039311630651388345.tmp/Tone.cpp:13: undefined reference to `noTone(unsigned char)'
C:\Users\CHRIST~1\AppData\Local\Temp\build6039311630651388345.tmp/Tone.cpp:15: undefined reference to `tone(unsigned char, unsigned int, unsigned long)'
Does this mean, that the function tone() is not part of the standard installation? I really can't see, what went wrong here. The compiler seems to recognize the functions, because it knows its parameters...
I found the file
arduino-1.0.1/hardware/arduino/cores/arduino/Tone.cpp
which seems to define the function (sorry, but this code is beyond my understandings).
I'm using an Arduino Uno Rev.3 on Windows 7 64bit.
Thanks for your help. (I moved this topic from Audio to this board, because I guess it really is a programming question)
Christoph