Skip to content

mostasin44/Digital-Clock

Repository files navigation

STM32 Multifunction Digital Clock System

A multifunction embedded digital clock system developed on the STM32F103 platform, featuring LCD-based real-time display, time regulation, alarm setting, status switching, race clock / stopwatch mode, infrared control, and USART-based PC communication.

This project was completed during my 5th semester Processor Principle internship in the Automation Major, College of Electrical Engineering and Control Science, Nanjing Tech University.


Project Overview

STM32 Digital Clock Project Figures

Figure: Hardware implementation, system block diagram, LCD interface examples, simplified circuit overview, IR control example, and USART communication workflow.

This repository presents a practical embedded systems project centered on the design and implementation of a multifunction digital clock using the STM32 microcontroller. The system goes beyond basic time display by integrating multiple interactive and communication-oriented modules into a single hardware-software platform.

The project was designed to strengthen practical understanding of:

  • microcontroller programming
  • embedded C development
  • timer and timing logic
  • LCD interfacing
  • alarm and state-based control
  • infrared communication
  • USART serial communication
  • hardware-software integration

This work reflects my undergraduate training and growing interest in embedded systems, automation, control, and intelligent hardware-software design.


Author

Sheikh MD Mostasin Ahammed
Major: Automation
College of Electrical Engineering and Control Science
Nanjing Tech University


Academic Context

This project was completed as part of my Processor Principle internship during the 5th semester of my undergraduate study. It represents one of my early hands-on embedded systems implementations involving real hardware, peripheral interfacing, and real-time control logic.


Objectives

The main objectives of this project were:

  • To design and implement a real-time embedded digital clock system using STM32
  • To display student information and current time on an LCD
  • To provide time regulation functionality for hour, minute, and second
  • To support alarm setting and reminder behavior
  • To implement multi-mode system switching
  • To build a race clock / stopwatch function with millisecond display
  • To integrate infrared-based external control
  • To enable USART communication with a PC for time regulation
  • To gain practical experience in embedded system design and implementation

Main Features

1. LCD Display Function

The LCD interface displays:

  • student name
  • student ID
  • current time in hour : minute : second
  • current operating mode
  • alarm time
  • key-based user instructions

This provides a simple and effective human-machine interface for real-time interaction.

2. Time Regulation Function

The system supports manual time regulation for:

  • hour
  • minute
  • second

Users can adjust the system time through onboard keys, making the clock flexible and interactive.

3. Alarm Setting Function

The project includes an alarm-setting function for reminder purposes. When the system time matches the preset alarm value, the corresponding alarm behavior is triggered.

4. Status Switching Function

The system supports switching between multiple operating states, such as:

  • normal clock mode
  • time adjustment mode
  • alarm setting mode
  • race clock / stopwatch mode
  • communication-related control modes

This demonstrates structured state-based control in embedded systems.

5. Race Clock / Stopwatch Function

A race clock function is implemented to support higher-precision timing. This mode can display:

  • seconds
  • milliseconds

It demonstrates timer-based precision control in an embedded application.

6. IR (Infrared) Control Function

The system supports infrared control functionality. This can be used for:

  • remote-style interaction
  • triggering simple external control behaviors
  • switching lights or similar devices
  • basic automation-related applications

This feature extends the project beyond simple clock behavior into interactive control.

7. USART Communication Function

The system supports USART communication with a PC. Using serial communication, the user can regulate:

  • hour
  • minute
  • second

This demonstrates PC-to-microcontroller interaction and serial communication design in embedded systems.


Functional Summary

Function Description
LCD Display Displays name, ID, time, mode, and alarm information
Time Regulation Adjusts hour, minute, and second
Alarm Setting Supports reminder/alarm time configuration
Status Switching Switches between different operating modes
Race Clock Displays seconds and milliseconds
IR Control Supports infrared-based external control
USART Communication Allows PC-based time regulation

Hardware Platform

The project was implemented on an STM32-based development platform with the following major components:

  • STM32F103RBTx microcontroller
  • LCD display module
  • onboard key/button interface
  • IR-related input/control module
  • USART serial communication interface
  • alarm/reminder output interface
  • supporting peripheral and power circuitry

Software and Development Environment

  • STM32CubeIDE
  • Embedded C
  • STM32 HAL Drivers
  • serial terminal / USART communication tools for PC-side testing

System Modules

Time Display Module

Responsible for displaying:

  • name
  • student ID
  • real-time clock value
  • current operating mode
  • alarm information

Time Regulation Module

Handles the adjustment of hour, minute, and second through user interaction.

Alarm Module

Stores alarm values and compares them with current system time.

Mode Management Module

Controls switching between normal, adjustment, alarm, stopwatch, IR, and USART-related modes.

Race Clock Module

Implements stopwatch-style timing with millisecond-level display.

IR Control Module

Supports infrared-based input and external control functionality.

USART Module

Supports communication with a PC for time regulation and control-oriented interaction.


User Interaction

The system uses onboard keys for user interaction. A typical key mapping is:

  • Key0: select or adjust target parameter
  • Key1: increment value
  • Key2: decrement value

This creates a compact and practical interface for configuration and control without additional external input hardware.


Engineering Concepts Demonstrated

This project demonstrates practical experience with:

  • embedded C programming
  • STM32 microcontroller development
  • timer configuration and timekeeping logic
  • LCD interfacing
  • key scanning and user input handling
  • alarm/event triggering
  • state machine design
  • infrared-based control
  • USART serial communication
  • hardware-software co-design

Why This Project Is Meaningful

This project is not limited to being a simple digital clock. It combines several foundational embedded systems concepts into one integrated implementation:

  • real-time timing logic
  • LCD-based human-machine interaction
  • user-driven parameter adjustment
  • alarm scheduling
  • multi-state system control
  • precision timing
  • infrared communication
  • serial communication with a host PC

For that reason, it represents a compact but meaningful demonstration of undergraduate-level practical capability in embedded systems and automation-oriented engineering.


How to Build and Run

  1. Clone this repository:
    git clone https://github.com/your-username/Digital-Clock.git

About

STM32-based multifunction digital clock with LCD display, alarm, stopwatch, IR control, and USART communication.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages