Hi
I am new to this forum.
tone() is not recognized in my Mac Arduino IDE 017. Did I have to put some #include statement before?
Thanks in advanced
Hi
I am new to this forum.
tone() is not recognized in my Mac Arduino IDE 017. Did I have to put some #include statement before?
Thanks in advanced
You need the tone library, and to include tone.h.
PaulS, thanks for your reply.
I've found elsewere that by upgrading to IDE 018 the tone() statement is automatically recognized. I've tested that and it works just fine.
Regards
Ercolino
That is because the tone library became official with version 18, and is now installed automatically.
Yup, tone() is included as part of the language in 0018, so you won't need to include the Tone library. But be aware that the implementation changed a bit.
For example in 0017 it would be:
#include <Tone.h>
const int audioPin = 7; // the pin you will use for the audio out
void setup() {
toneGenerator.begin(audioPin); // attach the pin to the tone object
}
void loop() {
toneGenerator.play(NOTE_A4);
}
While in 0018 it would be:
#include "tone_note_definitions.h" // this include is for the note names (optional, you will need to create this file -- they were built into the old library)
const int audioPin = 7; // the pin you will use for the audio out
void setup(){
// we don't need anything here now
}
void loop(){
tone(audioPin, NOTE_A4);
}