Dear Pololu’s support,
I have a functionnal Zumo now, but I’d like to add the buzzer and accelerometer features. From now, I’m playing with the buzzer.
But, I can not compile the code because of this error :
ZumoBuzzer/ZumoBuzzer.cpp.o: In function
ZumoBuzzer::playMode(unsigned char)': /usr/share/arduino/libraries/ZumoBuzzer/ZumoBuzzer.cpp:722: multiple definition of__vector_9’
ServoTimer2/ServoTimer2.cpp.o:/usr/share/arduino/libraries/ServoTimer2/ServoTimer2.cpp:94: first defined here
collect2: ld returned 1 exit status
What should I do ?
It looks like your code isn’t compiling because there are multiple conflicting definitions of the Timer2 overflow interrupt. The ZumoBuzzer library uses Timer2 to control the buzzer, so unfortunately, you won’t be able to use it along with any other library that uses Timer2.
ok fair enough, thank you for this answer.
So, I presumed that I can put the jumper and directly use a digitalWrite() on pin3 to play a note. But the zumo is still very quiet…
Do you have an idea on how should I fix it ?
You need to drive the buzzer pin at the frequency of the sound you want it to make. Just driving it steadily high could just burn it out. So, for example, if you want to play a 1 kHz note, you would drive the buzzer pin high for 500 us, low for 500 us, high for 500 us, low for 500 us, etc.
do you have a code sample ?
because I think it’s what I did :
but 128 it’s like medium right ?
so I should do :
and this code have no effetct :
analogWrite() only works on pins that are hardware PWM outputs. delay(500) is delaying for 500 ms, not 500 us. You need to use delayMicroseconds().
Ok Ben, Thx…
I understood this one, but the following is not working :
analogWrite(buzzer_PIN, HIGH); // pin 3
As I said, analogWrite() is only valid on hardware PWM pins. You should be using digitalWrite().
yes indeed, now it’s working. But how come the sound is so weak ?
Are you making the pin an output? Can you post your full program (it should only be a few lines long)?