This is an old revision of the document!


Smart Barrier Access System

Introduction

Smart Barrier Access System is an embedded system project that simulates an intelligent access control barrier, similar to those used in parking systems, restricted access areas, or automated gates. The project is built around an Arduino microcontroller and integrates multiple hardware and software modules to provide a secure and interactive access experience.

The system uses two proximity sensors to detect the presence and movement of a user around the barrier. When a person approaches the entrance area, the first sensor triggers the authentication sequence. The user must then enter a valid PIN code using a 4×4 membrane keypad within a limited time interval.

If the authentication is successful, the barrier is lifted using a servo motor. After the user passes through the access point, the second sensor confirms the passage and the barrier automatically closes. If the user fails to authenticate or no movement is detected after opening the barrier, the system safely returns to its initial state.

The main purpose of the project is to demonstrate the implementation of a real-time embedded access control system by combining sensors, motors, and authentication mechanisms, and state-based software control. The project integrates multiple concepts studied during Embedded Systems laboratories, such as GPIO, interrupts, PWM, timers, ADC, and I2C communication.

I believe the project is useful both from an educational and practical perspective. It offers a clear example of how hardware and software modules can interact in order to create an automated and secure control system. At the same time, it provides hands-on experience with designing PCBs, integrating multiple peripherals, implementing finite state machines, and developing modular embedded applications.

The project combines security, automation, and user interaction that can later be extended with RFID, IoT connectivity, or wireless communication features.

General Description

Hardware Modules

Arduino Nano - Main control unit. It coordinates all hardware modules, processes sensor inputs, validates the PIN code, and controls the barrier state.

Proximity Sensor 1 - Detects the presence of a user in front of the barrier and initiates the authentication sequence.

4×4 Membrane Keypad - Allows the user to enter the authentication PIN code.

Servo Motor (SG90) - Controls the physical position of the miniature barrier (open/closed).

Proximity Sensor 2 - Detects whether the user has successfully passed through the access point.

LCD 16×2 with I2C Interface - Displays system states and user messages such as:

  • “Enter PIN”
  • “Access Granted”
  • “Access Denied”
  • “Timeout”

LEDs - Provide visual and audio feedback depending on system state and authentication result.

System Workflow

1. User approaches the barrier

 -> Proximity Sensor 1 detects movement  
 -> System transitions from IDLE to WAIT_FOR_CONFIRM  
 -> LCD prompts user to enter PIN

2. User enters authentication code

 -> Keypad input is processed  
 -> Hardware timer starts countdown for timeout protection  
 -> PIN is validated

3. If PIN is correct

 -> Barrier opens using servo motor  
 -> Green LED indicates successful access  
 -> System enters WAIT_FOR_PASS state

4. User passes through the barrier

 -> Proximity Sensor 2 confirms passage  
 -> Barrier closes automatically  
 -> System returns to IDLE

5. Error handling

 -> Invalid PIN or timeout triggers error state  
 -> Red LED indicates failure  
 -> Barrier remains closed  
 -> System resets safely

State Machine Architecture

The software is implemented using a finite state machine (FSM) with the following states:

  • IDLE
  • WAIT_FOR_CONFIRM
  • OPENING
  • WAIT_FOR_PASS
  • CLOSING
  • ERROR

Block Diagram

Legend:

  • Sensors → Blue
  • User Inputs → Purple
  • Arduino / Control Unit → Orange
  • Actuators / Motors → Green
  • Display Module → Yellow
  • LED Indicators → Red

Hardware Design

Components Scheme

The hardware architecture of the project is centered around an Arduino Nano microcontroller integrated on a custom PCB designed in KiCad. The system combines multiple peripherals used for user detection, authentication, visual feedback, and motion control.

The access control mechanism is based on two IR proximity sensors positioned before and after the barrier. The first sensor detects the presence of a user near the access point and triggers the authentication process, while the second sensor confirms that the user successfully passed through the barrier.

User authentication is performed through a 4×4 membrane keypad connected to multiple digital GPIO pins of the microcontroller. The entered PIN is processed by the firmware and validated before allowing access.

The physical barrier is controlled using an SG90 servo motor driven through a PWM signal generated by the Arduino Nano. In addition, the project includes a DC motor controlled through an L298N H-Bridge motor driver, allowing bidirectional movement of the conveyor belt mechanism.

A 16×2 LCD display connected through the I2C interface is used to display system states, authentication messages, and user instructions in real time.

Two LEDs are used as visual status indicators:

  • Green LED → access granted
  • Red LED → invalid PIN or system error

The project also includes a custom-designed PCB containing routing, connectors, protection components, and dedicated headers for all external modules.

Electrical Schematic

schema_electrica_peiu.jpeg

The electrical schematic was designed in KiCad and includes all hardware connections used in the project, such as the Arduino Nano, IR sensors, LCD module, keypad interface, LEDs, and power circuitry.

PCB Design

pcb_front_peiu.jpeg pcb_back_peiu.jpeg

Pin Configuration

Component Arduino Nano Pin(s) Type Description
Proximity Sensor 1 todo Digital Input Detects user before barrier
Proximity Sensor 2 todo Digital Input Detects user after barrier
Servo Motor SG90 todo PWM Output Controls barrier movement
Keypad 4×4 todo Digital I/O Reads user PIN input
LCD 16×2 I2C todo I2C Interface Displays system messages
Green LED todo Digital Output Access granted indicator
Red LED todo Digital Output Access denied/error indicator

Additional Notes

  • Pins A4 and A5 are reserved for I2C communication with the LCD module.
  • The servo motor uses PWM for smooth positioning control.
  • Hardware timers are used to manage authentication timeout intervals.
  • Sensors are continuously monitored for event-driven transitions.

Bill of Materials (BOM)

Component Description Quantity
Arduino Nano Main microcontroller board 1
SG90 Servo Motor Barrier actuation mechanism 1
DC Motor Conveyor belt movement 1
L298N Motor Driver H-Bridge motor controller 1
4×4 Membrane Keypad PIN authentication input 1
IR Proximity Sensors User detection 2
LCD 16×2 with I2C User interface display 1
LEDs Visual feedback indicators 2
Custom PCB Hardware integration board 1
Jumper Wires / Connectors Electrical connections ~20
Resistors Current limiting and pull-up resistors Multiple

Software Design

Development Environment

The firmware was developed using:

  • Arduino IDE
  • Programming Language: C/C++
  • Target Platform: Arduino Nano (ATmega328P)

The software architecture is based on a finite state machine (FSM) implementation that manages all transitions between authentication, barrier control, and user detection states.

External Libraries Used

The following third-party libraries were integrated into the project firmware:

Library Purpose
Wire.h I2C communication support
LiquidCrystal_I2C.h LCD 16×2 display control
Keypad.h 4×4 keypad scanning and input processing
Servo.h Servo motor PWM control

These libraries simplify peripheral integration and allow modular firmware development.

Software Architecture

The application firmware is divided into multiple logical modules responsible for different hardware subsystems and control mechanisms.

Finite State Machine (FSM)

The entire system behavior is controlled using a finite state machine.

Implemented states:

State Description
ST_IDLE Waiting for user detection
WAIT_FOR_CONFIRM User PIN input state
OPENING Barrier opening and conveyor activation
WAIT_FOR_PASS Waiting for user passage
CLOSING Barrier closing and conveyor stop
EROARE Error and timeout handling

The FSM implementation provides:

  • modular control flow;
  • predictable state transitions;
  • easier debugging and testing;
  • scalable architecture for future extensions.

Authentication Module

The authentication subsystem is responsible for:

  • keypad scanning;
  • PIN storage;
  • PIN validation;
  • timeout protection.

Main features:

  • supports numeric PIN entry;
  • supports character deletion using '*';
  • PIN confirmation using '#';
  • automatic timeout reset after inactivity.

The authentication logic compares the entered PIN with a predefined secret code stored in firmware.

Sensor Monitoring Module

Two IR proximity sensors are continuously monitored:

Sensor Purpose
Front IR Sensor Detects user arrival
Rear IR Sensor Detects successful passage

The sensors are read using analog inputs and calibrated automatically during system startup.

Calibration process:

  • the firmware samples sensor values multiple times;
  • computes average environmental baseline;
  • dynamically generates detection thresholds.

This improves detection reliability and reduces false triggering.

Barrier Control Module

The physical barrier is controlled using an SG90 servo motor.

The firmware implements:

  • smooth opening movement;
  • smooth closing movement;
  • gradual angle transitions using incremental PWM updates.

Servo positions:

  • 0° → barrier closed;
  • 90° → barrier opened.

Movement timing is controlled through software delays to obtain smooth mechanical motion.

Conveyor Belt Control Module

The conveyor mechanism is controlled through an H-Bridge driver.

Implemented operations:

  • conveyor start;
  • conveyor stop;
  • motor direction control.

The conveyor starts only after successful authentication and stops automatically after user passage confirmation.

LCD Feedback System

A 16×2 I2C LCD module is used to provide real-time user feedback.

Displayed messages include:

  • system initialization;
  • PIN request;
  • access granted;
  • access denied;
  • timeout warnings;
  • error states;
  • conveyor and barrier status.

The LCD interface improves usability and debugging visibility.

LED Signaling System

Two LEDs are used for visual feedback:

LED Meaning
Green LED Access granted / active system
Red LED Access denied / error state

Implemented behavior:

  • both LEDs active in standby mode;
  • both LEDs off during authentication;
  • green LED active after successful authentication;
  • red LED active after invalid PIN;
  • red LED blinking during error state.

Timing and Timeout Management

The firmware uses non-blocking timing based on the millis() function.

Implemented protections:

  • PIN input timeout;
  • passage timeout;
  • automatic recovery after inactivity.

Advantages:

  • responsive behavior;
  • reduced blocking delays;
  • stable event processing.

Implemented Functions

State Management

Function Purpose
tranzitie() Handles FSM transitions

Sensor Functions

Function Purpose
irFata() Detects approaching user
irSpate() Detects completed passage

Barrier Functions

Function Purpose
servoMisca() Smooth servo movement control

Conveyor Functions

Function Purpose
bandaPorneste() Starts conveyor motor
bandaOpreste() Stops conveyor motor

LCD Functions

Function Purpose
lcdAfis() Updates LCD display messages

Implemented Embedded Concepts

The project integrates concepts from multiple Embedded Systems laboratory sessions:

Laboratory Concepts Used
GPIO LEDs, keypad, sensors
Timers & PWM Servo motor control
ADC IR sensor analog reading
I2C LCD communication
FSM Design System control logic

Software Optimizations

Several optimizations were implemented:

  • modular firmware structure;
  • state-based architecture;
  • automatic sensor calibration;
  • non-blocking timeout management;
  • smooth servo movement;
  • reduced LCD refresh flickering;
  • stable sensor polling.

System Workflow

  1. System waits in ST_IDLE.
  2. Front sensor detects user presence.
  3. User enters authentication PIN.
  4. If PIN is correct:
    • barrier opens;
    • conveyor belt starts;
    • green LED activates.
  5. Rear sensor confirms passage.
  6. Conveyor stops.
  7. Barrier closes.
  8. System returns to idle state.

In case of:

  • invalid PIN;
  • timeout;
  • missing passage confirmation;

the firmware transitions into an error handling state and safely resets the system.

Results

The final system successfully demonstrates:

  • automatic user detection;
  • secure PIN-based authentication;
  • automated barrier control;
  • real-time LCD feedback;
  • audio and visual signaling;
  • timeout and error handling.

The barrier responds reliably to user interaction and correctly manages all implemented states.

Github Repository

Demo Video

Project Images

Conclusion

The project successfully combines multiple embedded systems concepts into a practical and interactive application. It demonstrates how sensors, actuators, timers, communication protocols, and state machines can work together to create a functional access control system.

The implementation achieved all proposed objectives while also providing opportunities for future improvements such as:

  • RFID authentication;
  • Bluetooth/WiFi connectivity;
  • mobile application integration;
  • cloud logging system;
  • IoT monitoring.

Bibliography

Hardware Resources

  • Arduino Uno Datasheet
  • SG90 Servo Motor Datasheet
  • LCD 16×2 I2C Documentation

Software Resources

pm/prj2026/bianca.popa1106/andreea.peiu.1779704210.txt.gz · Last modified: 2026/05/25 13:16 by andreea.peiu
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