Try this code
The outputs are on pins 9 and 10
#include <avr/io.h>
#include <avr/interrupt.h>
//---------------------------
// Interrup Service Routines
// To PWM LED for debugging
ISR(TIMER1_COMPA_vect)
{
PORTB &= ~_BV(PB5);
}
ISR(TIMER1_OVF_vect)
{
PORTB |= _BV(PB5);
}
//---------------------------
void setup()
{
// Set-up GPIOs
DDRB |= _BV(PB5); // LED
DDRB |= _BV(PB1); // OC1A output pin 9
DDRB |= _BV(PB2); // OC1B output pin 10
PORTB &= ~ _BV(PB5); // Turn off LED
// Set-up Timer 1 for PWM
// ICR1H and ICR1L – Input Capture Register 1 (NOT used)
// Fast PWM mode 6, prescaler = 1
// output on OC1A, inverted on OC1B
TCCR1A = 0b10110010; // COM1A1 COM1A0 COM1B1 COM1B0 0 0 WGM11 WGM10
TCCR1B = 0b00001001; // ICNC1 ICES1 0 WGM13 WGM12 CS12 CS11 CS10
TCCR1C = 0;
OCR1A = 128;
OCR1B = 128;
TCNT1 = 0;
// Enable interrupts to PWM the LED (for debugging)
// Delete if not wanted
TIMSK1 |= (_BV(OCIE1A) | _BV(TOIE1)); // Interrupt Mask Register
// TIFR1 = 0x00; // Interrupt Flag Register
}
void loop()
{
// Change the PWM Duty Cycle
for (int i=1; i<512; i++)
{
OCR1A = i;
OCR1B = i;
delay(5);
}
}