This project demonstrates Pulse Width Modulation (PWM) using Timer1 of the ATmega328P (Arduino UNO) — entirely through register-level programming, no Arduino functions involved.
- Arduino UNO (ATmega328P)
- LED connected to pin D9 (OC1A)
- 220Ω current-limiting resistor
| Component | Function | Arduino Pin | Port |
|---|---|---|---|
| LED | PWM Output | D9 | PB1 (OC1A) |
| VCC | Power | +5V | — |
| GND | Ground | GND | — |
| Register | Purpose |
|---|---|
| TCCR1A | Controls PWM mode and output behavior |
| TCCR1B | Sets waveform generation mode and prescaler |
| OCR1A | Output Compare Register (sets duty cycle) |
| DDRB | Configures PB1 as output |
- Mode: Fast PWM (10-bit resolution)
- Output: Non-inverting mode
- Prescaler: 64
- PWM Frequency: ~250 kHz
- Output Pin: OC1A (PB1 → Arduino D9)
- Timer1 generates a PWM signal at OC1A pin.
- The duty cycle is adjusted from 0 → 100% → 0 in a smooth fade loop.
- LED brightness increases and decreases continuously.
- Compile using AVR-GCC / Atmel Studio / PlatformIO.
- Flash the HEX file to Arduino UNO.
- Observe the LED brightness fading up and down using hardware PWM.