#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!

Join diydrones

Email me when people reply –

Replies

This reply was deleted.

Activity