This is an old revision of the document!
Password-Protected Alarm System
Introduction
This project implements a password-protected alarm system using the Arduino Nano ATmega328P board.
What it does: The system activates a passive buzzer alarm that can only be silenced by entering the correct password via push buttons. A green LED confirms a correct entry, while a red LED and an intensified alarm sound signal an incorrect attempt. A reset button and an LCD display are also integrated.
General Description
The system is structured around the following hardware and software modules:
Hardware Modules:
ATmega328P X-Mini — the central processing unit
Passive Buzzer — driven by PWM (Timer1) to produce variable-frequency alarm tones
Push Buttons (4x) — used to input the password digits (e.g. a 4-button combination lock)
Reset Button — triggers a software or hardware reset of the system state
Green LED — indicates correct password entry
Red LED — indicates wrong password entry
16×2 LCD Display — displays system status messages
Bill of Materials:
| Component | Quantity | Notes |
| —————————- | ———- | ———————————— |
| Arduino Nano ATmega328P | 1 | 16 MHz, 5V |
| Passive buzzer | 1 | Sound |
| Push buttons | 4 | Password input, pull-up resistors |
| Reset button | 1 | Reset purpose |
| Green LED + 220Ω resistor | 1 | Correct password indicator |
| Red LED + 220Ω resistor | 1 | Wrong password indicator |
| 16×2 LCD (HD44780) | 1 | I2C adapter |
| Breadboard + jumper wires | - | Prototyping |
| USB cable | 1 | For flashing the ATmega328P |
Electrical Notes:
All push buttons are wired with the internal pull-up resistors enabled (INPUT_PULLUP equivalent in bare metal: set DDRx bit to 0 and PORTx bit to 1). Buttons are active-low.
LEDs are connected through 220Ω current-limiting resistors to GND.
Algorithms and Structures:
The system uses a simple finite state machine with 5 states:
`IDLE` — system waiting, buzzer silent
`ARMED` — alarm active, buzzer playing alarm melody via PWM
`INPUT` — user is entering the password sequence
`CORRECT` — correct password: green LED on, buzzer off, LCD shows “ACCESS GRANTED”, auto-return to IDLE after timeout
`WRONG` — wrong password: red LED on, buzzer plays intensified tone, LCD shows “ACCESS DENIED”, auto-return to ARMED
Software design
Editor: VS Code with the C and “AVR Utils” extensions for syntax highlighting and register lookup
Debugging: LED-based state signaling and logic analyzer on PWM/GPIO lines
Target: ATmega328P X-Mini
Libraries and 3rd-party sources:
`avr/io.h` — direct register-level access to all ATmega328P peripherals (DDRx, PORTx, PINx, TCCRx, OCRx, etc.)
`avr/interrupt.h` — enabling global interrupts (sei/cli) and defining ISR handlers
`util/delay.h` — used exclusively in the LCD initialization sequence and LED hold timers; all alarm timing is handled via hardware timers
Block Design
Laboratories Used:
*The implementation of this project is based on the concepts studied in the following laboratories:
Laboratory 0 GPIO - Used for basic interfacing. I configured the pins for the LEDs as outputs and the pins for the push buttons as inputs with internal pull-up resistors enabled.
Laboratory 1 UART - Integrated for debugging purposes. The system transmits the current state and the entered sequence to a Serial Monitor, allowing for real-time monitoring of the logic.
Laboratory 2 Interrupts - Used for the reset button and potentially for handling button presses to ensure immediate response from the microcontroller without constant polling in the main loop.
Laboratory 3 Timers - Essential for the acoustic feedback.
Laboratory 6 I2C - Essential for the UX.
Schematics
Pins Layout
| Arduino Nano Pin | Pin Type | Connected Component | Functional Description |
| —————— | —————– | ———————- | ——————————————– |
| D2 | Input | SW_Push (Reset) | System reset button |
| D3 | Input | SW4 | Password input button |
| D4 | Input | Start | Process start / arming button |
| D5 | Input | SW1 | Password input button |
| D6 | Input | SW3 | Password input button |
| D7 | Input | SW2 | Password input button |
| D8 | Output | D2 (Red LED) | “Access Denied” indicator (via 220Ω R1) |
| D9 | Output | D1 (Green LED) | “Access Granted” indicator (via 220Ω R2) |
| D10 | Output (PWM) | BZ1 (Buzzer) | Acoustic alarm / feedback signal |
| A4 | I/O (SDA) | J1 (LCD I2C) | I2C data line |
| A5 | I/O (SCL) | J1 (LCD I2C) | I2C clock line |
Results
Conclusions
Download
Journal
Bibliography / Resources