void setup() {
volatile char *dir;
dir=0x101;
*dir|= (1 << DDH6); // DDRH controls the direction of PORT H pins, DDH6 corresponds to PH6 (pin 9)
// Set up Timer2 for Fast PWM mode
TCCR2A |= ~(1 << COM2B0) | (1 << WGM20) | (1 << WGM21); // Non-inverting mode, Fast PWM (TOP = 0xFF)
}
void loop() {
uint8_t brightness;
for (brightness = 0x00; brightness <= 0xFF; brightness++) {
// Set the duty cycle for PH6 (pin 9) duty cycle pin
OCR2B = brightness;
delay(3);
}
for (brightness = 0xFF; brightness >= 0x00; brightness--) {
// Set the duty cycle for PH6 (pin 9)
OCR2B = brightness;
delay(12);
}
}