You're in luck my friend. Another user found this to work (albeit with a different requirement). I made the changes to match your requirement. Give it a shot.
int analogPin = A0;
int val = 0;
uint16_t duty = 0;
void setup() {
// put your setup code here, to run once:
PWM_init();
}
void loop() {
// put your main code here, to run repeatedly:
val = analogRead(analogPin);
duty = map(val, 0, 1023, 0, 22500);
OCR1B = duty;
delay(50);
}
void PWM_init(void)
{
/***************************
Initialize the PWM hardware
***************************/
// set OC1B output pin
DDRB |= 1<<PORTB2;
// set TIMER1 for Fast PWM mode, non-inverted output on OC1B pin
TCCR1A = 1<<WGM11 | 1<<WGM10 | 1<<COM1B1 | 0<<COM1B0;
TCCR1B = 1<<WGM13 | 1<<WGM12;
// disable interrupts
TIMSK1 = 0<<OCIE1B | 0<<OCIE1A | 0<<TOIE1;
// set TOP value to generate initial 10 Hz [250 KHz / 25000]
OCR1A = (25000 - 1);
// set initial duty cycles at 10%
OCR1B = 2500;
// start TIMER1 at 250 KHz [DIV64]
TCCR1B = 1<<WGM13 | 1<<WGM12 | 0<<CS12 | 1<<CS11 | 1<<CS10;
return;
}
Potentiometer input on A0 and PWM signal out on D10