So I'm new to the arduino and I"m trying to understand the programming for PWM. What I want to know is if I change a pin's frequency, will that effect how analogWrite() sets a duty cycle?
For example, Can I set pin 9's frequency to 31.250kHz like so:
void setup()
{Serial.begin(9600);
pinMode(3,OUTPUT);
TCCR2B = TCCR2B & 0b11111000 | 0x01;
}
Then manipulate the duty cycle to 20% using analogWrite(), like this:
void loop()
{analogWrite(3,0.20*255)
}
or does changing the frequency cause the value of 255 to change? ...Or something else entirely?