This project demonstrates how to configure and handle external interrupts (INT0 & INT1) on the ATmega328P at the register level, without using Arduino functions.
- Arduino UNO (ATmega328P)
- 2 Push Buttons (for INT0 & INT1)
- LED (on pin 13, PB5)
- 10kΞ© Pull-down or Pull-up Resistors (if needed)
| Component | Function | Arduino Pin | Port |
|---|---|---|---|
| Push Button 1 | External Interrupt 0 | D2 | PD2 / INT0 |
| Push Button 2 | External Interrupt 1 | D3 | PD3 / INT1 |
| LED | Output | D13 | PB5 |
| VCC | Power | +5V | β |
| GND | Ground | GND | β |
| Register | Purpose |
|---|---|
| DDRB | Configure PB5 as output |
| SREG | Global Interrupt Enable (bit 7) |
| EIMSK | Enable specific external interrupts (INT0, INT1) |
| EICRA | Set interrupt trigger edge (rising, falling, etc.) |
- INT0 (D2) β When pressed, triggers ISR β LED ON
- INT1 (D3) β When pressed, triggers ISR β LED OFF
- Button 1 (INT0) sends a rising edge β LED turns ON.
- Button 2 (INT1) sends a rising edge β LED turns OFF.
- The CPU sleeps in the main loop until an interrupt occurs.
- Compile with AVR-GCC / Atmel Studio / PlatformIO.
- Upload the HEX to Arduino UNO.
- Observe LED toggling as external interrupts occur.