hi
I have a question.
Why can't I dirve the servo with this sketch:
///////////////////////////////////////////////
#include <avr/interrupt.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
#define MAX 419
volatile int servo=171;
void setup() {
Serial.begin(9600);
pwm.begin();
pwm.setPWMFreq(50);
cli();
TCCR3A = 0;
TCCR3B = 0;
TCNT3 = 0;
OCR3A = 50000;
TCCR3B |= (1<<CS31);
TCCR3B |= (1<<WGM32);
TIMSK3 |= (1<<OCIE3A);
sei();
}
ISR(TIMER3_COMPA_vect)
{
if(servo<=MAX)
{servo++;
pwm.setPWM(0, 0, servo);
}
else{
servo = 171;
}
}
void loop(){}
/////////////////////////////////////////
Used software: Arduino
I'm using an Arduino MEGA 2560.
For the servo, I use the adafruit-16-channel-pwm-slash-servo-shield.
Without using timer, the servo drives.
So what's wrong here??
Thanks in advance