Skip to main content
Version: ACS CC

Security System

A smart access control system using username and PIN authentication

info

Author: Iulia-Elena Giuroiu
GitHub Project Link: source code

Description

This project implements a smart security system for controlling access to a restricted area. Authentication is based on a 4-character username and a 4-digit PIN entered via a matrix keypad. Only one person is allowed inside at any given time. If motion is detected without valid authentication, an alarm is triggered using a buzzer and flashing red LED.

Motivation

The motivation behind this project is to combine embedded programming with real-world security applications. It provides a simple but effective way of managing access, detecting unauthorized entries, and signaling alerts.

Architecture

The system is organized modularly, with each logic component responsible for a distinct functionality. They communicate through events triggered by sensors and shared internal states.

Main architectural components:

  • Authentication Module – handles input and validation of username and PIN
  • Access Control – controls the servo motor that opens or closes the door
  • Alert Module – detects unauthorized movement and activates the red LED and buzzer
  • Display Module – shows messages on an OLED or LCD screen
  • State Management – allows access for only one person at a time

Flowchart Diagram

Log

Week 5 - 11 May

Week 12 - 18 May

Week 19 - 25 May

Hardware

The system uses two Raspberry Pi Pico 2W boards. The main board handles authentication, motor control, and alert logic, while the second board is optional for debugging or logging. All components interact via GPIO, PWM, and I²C protocols.

Hardware DevicePurposeUsage
Raspberry Pi Pico 2WMain microcontrollerControls authentication, logic, and peripherals
Raspberry Pi Pico 2W (Debug)DebuggingUART logging and state tracing
Matrix Keypad 4x4InputUser input for username and PIN
PIR Motion Sensor HC-SR501DetectionTriggers alert on unauthorized motion
Micro Servo SG90 180°ActuatorControls door movement
Buzzer 3V/5VAlertSound alarm on intrusions
LEDs (Red, Green)IndicatorsRed = alert, Green = access granted
LCD 1602 I2CDisplayShows system messages
Breadboard (400 & 830 pts)PrototypingAssembling components
Resistors (220Ω – 1kΩ)SafetyLimits LED current
USB Power SupplyPowerPowers boards and modules

Schematics

Electrical Schematic

Bill of Materials

ProductPurposeQuantityUnit PriceTotal Price
PIR Motion Sensor HC-SR501Movement detection15.99 lei5.99 lei
Matrix Keypad 4x4User input16.99 lei6.99 lei
LCD 1602 I2C (Yellow-Green)Display114.99 lei14.99 lei
Buzzer 3VAudio signal10.99 lei0.99 lei
Breadboard HQ 400ptsAssembly14.56 lei4.56 lei
Breadboard HQ 830ptsExpanded assembly19.98 lei9.98 lei
Raspberry Pi Pico 2WMain + debug boards239.66 lei79.32 lei
Green LED 3mmVisual indicator30.39 lei1.17 lei
Red LED 3mmVisual alert30.39 lei1.17 lei
SG90 ServoDoor control111.99 lei11.99 lei

Software

The firmware is written in Rust using an asynchronous multitasking model powered by Embassy.

Core features

  • Async architecture with no RTOS required
  • Rust embedded: fully safe, low-level control over peripherals
  • Efficient resource usage on the RP2040 dual-core microcontroller

Tasks

  • Authentication Task: Reads input from the keypad, validates username and PIN
  • Access Task: Controls the door via the servo motor and manages door state logic
  • Alert Task: Listens for motion events from the PIR sensor and activates the buzzer and red LED if motion is detected without authentication
  • Display Task: Shows real-time messages and system prompts via the LCD1602 using I²C

Peripheral Handling

  • GPIO: Used for keypad input, LED control, and buzzer signal
  • PWM: Drives the buzzer and smoothly dims LEDs
  • I²C: Communication with the LCD display
  • Task synchronization: Performed using Embassy's async/await runtime, avoiding blocking calls and ensuring responsive behavior
  1. RP2040 Documentation
  2. SSD1306 Rust driver
  3. rp-hal examples
  4. PIR sensor datasheet