Hello,
I'm building an autonomous robot, I'm using an arduino Mega 2560. I want to implement Timer Interrupts, in combination with sensors and two motor controllers. I'm having trouble compiling my code when I include the timer interrupt and the servo library along with different servo calls for my two motor controllers. Now I'm using timer 3 and this is the code for how i set it up
void setup()
{
pinMode(ledPin, OUTPUT);
// initialize timer1
cli(); // disable all interrupts
TCCR3A = 0; // Clean the registers
TCCR3B = 0;
TCCR3B |= (1 << WGM12); // Mode 4, CTC
OCR3A = 16383; // 1/4 of counter
TCCR3B |= (1 << CS32) | (1 << CS30); // Prescaler 1024
TIMSK3 |= (1 << OCIE3A); // enable compare A Match Interrupt
sei(); // enable all interrupts
}
. Now i tried your code along with some if statements including the servo calls, and its giving me an error "error compiling...." something about the servo library about having a vector already defined. Now i have comment out the servo calls, declarations and library and the code compiles, the same way I comment out the timer interrupts and the code compiles. I just wanted to know why is that if you want i could paste my code here.... I didnt use timer1 since its for the servo library as you mention. Well any feedback will be appreciated