int a=180;
int b=50;
int c=0;
void setup()
{
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(44,OUTPUT);
pinMode(45,OUTPUT);
pinMode(46,OUTPUT);
TCCR5A = _BV(COM5A1) | _BV(WGM50);
TCCR5B = _BV(WGM52) | _BV(CS52) | _BV(CS50); // Prescaler = 1024
OCR5A = 156; // 20 millisecond period
OCR2B = 8;
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS22);
//TCCR2B |= (1 << CS12) | (1 << CS10);
//TCCR2B = 0x05;
OCR2A = 156;
OCR2B = 8;
TCCR4B = 0;
TCCR4A = 0;
// Set the clock prescale to 1
//TCCR4B |= (1<<CS10);
TCCR4B = 0b11000101;
//TCCR5B = _BV(WGM52) | _BV(CS52) | _BV(CS50);
// Set TOP to 3999.
// Frequency is 16 MHz / (prescale * (TOP+1)) == 4 kHz.
ICR4 = 310;
// Start at 50% Duty Cycle
OCR4A = 8;
// Set mode to 14: FastPWM using ICR for TOP
TCCR4A |= 1<<WGM41;
TCCR4B |= (1<<WGM42| (1<<WGM43)) ;
// Select non-inverting FastPWM (higher numbers give higher duty cycle)
TCCR4A |= (1<<COM4A1);
Serial.begin(9600);
}
void loop()
{
for(int i=8;i<22;i=i+10){
OCR4A =i;
delay(250);
Serial.println(OCR4A);
//OCR4A=20;
}
Serial.print("Counter Ticks = ");
//Serial.println(TCCR4B,BIN);//TCNT5
}