You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This project demonstrates how to configure and handle external interrupts (INT0 & INT1) on the ATmega328P at the register level, without using Arduino functions.
⚙️ Hardware Used
Arduino UNO (ATmega328P)
2 Push Buttons (for INT0 & INT1)
LED (on pin 13, PB5)
10kΩ Pull-down or Pull-up Resistors (if needed)
🔌 Pin Configuration
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
—
🧩 Code Explanation
Key Registers Used
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.)
Logic
INT0 (D2) → When pressed, triggers ISR → LED ON
INT1 (D3) → When pressed, triggers ISR → LED OFF
⚙️ Working Principle
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.
🧰 Build & Upload
Compile with AVR-GCC / Atmel Studio / PlatformIO.
Upload the HEX to Arduino UNO.
Observe LED toggling as external interrupts occur.
About
This project demonstrates how to configure and handle **external interrupts (INT0 & INT1)** on the **ATmega328P** at the register level, without using Arduino functions.