[solved]Basic problem with tone()-function: Does not compile

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
 tone(speakerPin, f); 


This is the error code:

[code] Tone.cpp.o: In function loop': C:\Users\CHRIST~1\AppData\Local\Temp\build6039311630651388345.tmp/Tone.cpp:13: undefined reference tonoTone(unsigned char)' C:\Users\CHRIST~1\AppData\Local\Temp\build6039311630651388345.tmp/Tone.cpp:15: undefined reference to `tone(unsigned char, unsigned int, unsigned long)' [/code]

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


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)


I really can’t see, what went wrong here.

Neither can I. Your code compiles fine for me in IDE 1.0.1, 1.0 and 0023.

EDIT: Actually, I think I can. Have you named your sketch Tone? That will cause a conflict with the Arduino’s core Tone.cpp file.

I found the error :roll_eyes:

I named my sketch "Tone" which must have been the problem. The sketch name compiles fine.... :blush:

edit: just saw your edit, dxw00d, lol. Yes, that really was the problem. Thanks for your effort.