Here is my code, it works, I can get a frequncy output that is stable. However I can not tune the frequency to my precise value. I have tried changing the analogwrite function from 128 to 255 with no change.
Can any body advise if this can be done.
void setup()
{
TCCR1B = TCCR1B & 0b11111000 | 0x01; //0-7 for the last number
pinMode(9, OUTPUT); // enable the PWM output (you now have a PWM signal on digital pin 10)
}
void loop()
{
analogWrite(9,128); // set the PWM to 50% duty cycle
Yep your right, I got that page info pointed to me from another post.
I am curious though about why doesn't the change in the width of the pulse change the frequency. Or does it flip the off time with the width of the on time.
Because the frequency is the reciprocal of the high time plus the low time of a pulse. All you are doing is altering the ratio of each but the total remains the same.