/* ******************************************************** */
/* Example 10.1. Timer counter 1 as a PWM generator */
/* Modulates LED connected on PB5, SW1 and SW2 changes duty */
/* SW3 and 4 control the red LED */
/* Warning: The values are NOT CORRECT, they should be re- */
/* placed by students themselves!!! */
/* ******************************************************** */
#include <avr\io.h>
#define SW1 0
#define SW2 1
#define SW3 2
#define SW4 3
#define RedLED 5
int main(void) {
/* *********************** Init device ******************************** */
DDRB = 0b00000000; //
PORTB = 0b00000000; //
DDRC = 0b00000000; //
PORTC = 0b00000000; //
/* *********************** Init T1 as a PWM generator *************************** */
TCCR1A = 0b00000000; // Mode: PWM, Phase Correct, 9-bit
TCCR1B = 0b00000000; // Prescaler 1:1024
OCR1A = 000; // Initialization values
OCR1B = 000; // for 1:1 duty cycle
TCNT1 = 0;
for (;;);
}