Hey, i got this ShiftPWM Library: https://github.com/elcojacobs/ShiftPWM/downloads
At the beginning of the code i got this statement: #define SHIFTPWM_USE_TIMER2
If i just uncomment this i get this error message: "The avr you are using does not have a timer3"
The problem is that i also want to play a tone on my piezo buzzer. Therefore i got this code:
for (int thisNote = 0; thisNote < 8; thisNote++) {
int noteDuration = 1000/noteDurations[thisNote];
tone(12, melody[thisNote],noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(12);
}
Which is working fine in a single project, but combined with the shiftpwm library and its define statment i get the following error message:
core.a(Tone.cpp.o): In function `__vector_7':
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Tone.cpp:523: multiple definition of `__vector_7'
ShiftPWM_RGB_Example.cpp.o:/Users/david/Documents/Arduino/libraries/ShiftPWM/ShiftPWM.h:190: first defined here
So i went to the Tone.cpp file and i saw that there is also an timer2 statement which (in my opinion) causes this error.
I am new to this arduino stuff and i can make some minor bug fixes or something like that, but this error is too complicated for me at this time.
Do you have an idea how i can solve the puzzle ?
Btw if it helps you these are line 190 following from ShiftPW:
#elif defined(SHIFTPWM_USE_TIMER2)
//Install the Interrupt Service Routine (ISR) for Timer1 compare and match A.
ISR(TIMER2_COMPA_vect) {
ShiftPWM_handleInterrupt();
}
and line 523 following from Tone.cpp:
ISR(TIMER2_COMPA_vect)
{
if (timer2_toggle_count != 0)
{
// toggle the pin
*timer2_pin_port ^= timer2_pin_mask;
if (timer2_toggle_count > 0)
timer2_toggle_count--;
}
else
{
// need to call noTone() so that the tone_pins[] entry is reset, so the
// timer gets initialized next time we call tone().
// XXX: this assumes timer 2 is always the first one used.
noTone(tone_pins[0]);
// disableTimer(2);
// *timer2_pin_port &= ~(timer2_pin_mask); // keep pin low after stop
}
}