Problem with tone library

hello, so i have this error while testing the tone library :

Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer0_pin_port'
libraries\Tone\Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer0_pin_mask'
libraries\Tone\Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer1_pin_port'
libraries\Tone\Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer1_pin_mask'
libraries\Tone\Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer2_pin_port'
libraries\Tone\Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer2_pin_mask'
libraries\Tone\Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer0_toggle_count'
libraries\Tone\Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer1_toggle_count'
libraries\Tone\Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `timer2_toggle_count'
libraries\Tone\Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `__vector_7'
libraries\Tone\Tone.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
Plusieurs bibliothèque trouvées pour "Tone.h"
Utilisé : C:\Users\Galix\OneDrive\Documents\Arduino\libraries\Tone
Non utilisé : C:\Program Files (x86)\Arduino\libraries\Tone
exit status 1
Erreur de compilation pour la carte Arduino Nano

``


and here's my code if you want (basically the simpliest code ever) :

#include <Tone.h>

int speaker = 9;

void setup() {
  tone(speaker, 440,1000);
}
 
void loop() {}

Which Arduino board are you using ?

"la carte Arduino Nano"

With that "Tone" library you need to create a Tone object, such as:

#include <Tone.h>

Tone tonePin;

const uint8_t speaker = 9;

void setup() 
{
    tonePin.begin(speaker);
    tonePin.play(NOTE_A4);
    delay(1000);
    tonePin.stop();
}
 
void loop() {}
1 Like

ok thank you

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.