This is an old revision of the document!
Name: Dascalu Stefan-Nicolae
Group: 331CA
eSafe is a digital lockbox implemented on an Arduino Uno. It uses a 4×4 matrix keypad for PIN entry, an SG90 servo for a mechanical latch, a DS1307 real-time clock (I²C) to enforce access windows, and a 16×2 I²C LCD to display status and time. Three wrong PIN attempts trigger an alarm tone and flashing red LED; valid entries drive the servo to unlock, light a green LED, and display “UNLOCKED.”
This project integrates functionalities from three labs:
In Tinkercad I used a generic 7-segment I²C display; the real build uses the DS1307 module on the same SDA/SCL, so no rewiring or code changes are needed.
Component | Interface | Arduino pin | Direction | Rationale |
---|---|---|---|---|
Keypad row/col | GPIO | D2–D9 | input | Pin-change ISR on D2–D5; columns polled on D6–D9 |
Passive buzzer | GPIO | D11 | output | direct drive with tone()/noTone() |
Red LED | GPIO | D13 | output | Built-in LED pin |
Green LED | GPIO | D12 | output | Digital status LED (no PWM on D12) |
Servo SG90 | PWM | D10 | output | attach() supports D10 |
LCD I²C | I²C (TWI) | A4/A5 | bidir | Hardware Wire bus |
RTC DS1307 | I²C (TWI) | A4/A5 | bidir | Shares same TWI bus |
Component | Purchase link |
---|---|
Arduino Uno R3 (ATmega328P) | https://www.optimusdigital.ro/ro/placi-avr/4561-placa-de-dezvoltare-compatibila-cu-arduino-uno-r3-atmega328p-atmega16u2-cablu-50-cm.html |
4×4 Matrix Keypad | https://www.optimusdigital.ro/ro/senzori-senzori-de-atingere/470-tastatura-matriceala-4x4-cu-conector-pin-de-tip-mama.html |
DS1307 RTC Module (I²C) | https://www.optimusdigital.ro/ro/altele/4746-modul-ceas-in-timp-real-ds1307.html?search_query=Modul+Ceas+in+timp+real+DS1307&results=3 |
LCD 1602 I²C Blue Backlight | https://www.optimusdigital.ro/ro/optoelectronice-lcd-uri/2894-lcd-cu-interfata-i2c-si-backlight-albastru.html |
SG90 Micro-Servo | https://www.optimusdigital.ro/ro/motoare-servomotoare/26-micro-servomotor-sg90.html?search_query=Micro+Servomotor+SG90+90° |
Breadboard + jumper wires + LEDs + resistors | https://www.optimusdigital.ro/ro/kituri/12026-kit-plusivo-pentru-introducere-in-electronica-0721248990075.html |
* ~200 lines of custom C++ on Arduino Uno integrating all core features * PIN entry with 4×4 matrix scan, three-strike alarm, and time-based lockout fully tested * Live clock updates, non-blocking unlock/relock, and persistent last-unlock log verified in hardware
Library | Purpose | Justification |
——————— | —————————– | ————————————————– |
Wire / RTClib | I²C bus & DS1307 driver | proven reliability, minimal API for RTC access |
LiquidCrystal_I2C | HD44780 LCD over I²C | reduces wiring and boilerplate, easy print() API |
Keypad | matrix scan & debounce | built-in interrupt support and debounce logic |
Servo | SG90 control | official Arduino, handles PWM timing internally |
* Non-blocking relock (Lab 3 – Timers): replaced `delay(5000)` with a `millis()` timestamp so the 5 s unlock interval doesn’t freeze the clock display. * Interrupt-driven keypad (Lab 2 – GPIO/Interrupts): uses pin-change interrupts on rows and Timer2 CTC for debounce to guarantee responsive PIN capture. * Shared I²C bus (Lab 6 – I²C): demonstrates multi-device communication between the DS1307 RTC and the PCF8574-based LCD expander.
1. updateDisplay()
2. handleKey()
3. unlockDoor()
4. loop()
* Debounce tuning: Timer2 CTC interval set to 60 ms based on oscilloscope measurements of switch bounce. * Servo angles: adjusted to 20° (unlock) and 110° (lock) for mechanical reliability. * Blocking calls minimized: only a 1 s buzzer delay remains; all longer waits use non-blocking `millis()` logic.
eSafe demonstrates integration of GPIO, interrupts, timers, PWM, and I²C into a user-friendly digital safe. Non-blocking design ensures smooth UI and reliable timekeeping.