#include <avr/interrupt.h>
// This is using the 16-bit timer. 10-bit pwm
void setup() {
// TCCR1B
// Bit 7 6 5 4 3 2 1 0
// Bit Name COM1A1 COM1A0 COM1B1 COM1B0 ----- ----- WGM11 WGM10
// Initial Value 0 0 0 0 0 0 0 0
// changed to 1 1 1 1 0 0 1 0
TCCR1A = B11110010;
// TCCR1B
// Bit 7 6 5 4 3 2 1 0
// Bit Name ICNC1 ICES1 ----- WGM13 WGM12 CS12 CS11 CS10
// Initial Value 0 0 0 0 0 0 0 0
// changed to 0 0 0 1 1 0 0 1
// CS12,CS11,CS10 = (0,0,1) System clock, no division
TCCR1B = B00011001;
TCCR1B = 25;// 00011001
ICR1 = 1023 ; // 10 bit resolution
OCR1A = 511; // vary this value between 0 and 1024 for 10-bit
precision
OCR1B = 511; // vary this value between 0 and 1024 for 10-bit
precision
pinMode (10, OUTPUT);
}
void loop()
{
unsigned int n;
for (unsigned int i = 0; i <1024; i++) {
OCR1A = i;
OCR1B = i;
delay (1);
}
}
You need to be a member of diydrones to add comments!
Replies
Hi Mayank
do you think this will allow me to add an extra servo to APM?
Specifically this is what i'm talking about http://diydrones.com/forum/topics/servo-connected-to-expansion-port...
Any help will be really appreciated
Thanks
Adrian