Hi I've been trying to control my LEDs brightness using PWM but not all my LEDs are connected to a PWM port. How do I do it? I'm using an arduino uno, and I have a button on PD3. I'm quite new to this so there might be some errors in my code below. (Edit: I can't use normal arduino IOs such as digitalWrite, analogWrite and etc)
void setupTimer2FastPWM(void) {
TCCR2A = 0x23;
TCCR2B = 0x04;
DDRD = 0xF0;
DDRB = 0x0F;
}
void brightness_control() {
if ((PIND&0x08)==0)
{
if(OCR2B<255) {
OCR2B-=5;
} else {
OCR2B+=5;
}
}
Serial.print(OCR2B);
Serial.print(" ");
delay(200);
if (cnt != 5)
return;
}