This is an old revision of the document!


Password-Protected Alarm System

Introduction

This project implements a password-protected alarm system using the ATmega328P microcontroller 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
—————————-———-————————————
ATmega328P X-Mini board 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:

  • Password Validation FSM:

The system uses a simple finite state machine with 5 states:

  1. `IDLE` — system waiting, buzzer silent
  2. `ARMED` — alarm active, buzzer playing alarm melody via PWM
  3. `INPUT` — user is entering the password sequence
  4. `CORRECT` — correct password: green LED on, buzzer off, LCD shows “ACCESS GRANTED”, auto-return to IDLE after timeout
  5. `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:

  1. 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.
  2. 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.
  3. 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.
  4. Laboratory 3 Timers - Essential for the acoustic feedback.

Results

Conclusions

Download

Journal

Bibliography / Resources

pm/prj2026/theodor_ioan.buliga/bianca.buga.1777849908.txt.gz · Last modified: 2026/05/04 02:11 by bianca.buga
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0