Build an Alarm Reminder System in Python

Published on: May 29, 2026
Reading time: 5 minutes
Sistema de lembretes e alarmes desenvolvido com Python

Building an alarm reminder system in Python is one of the most rewarding projects for anyone taking their first steps in programming. Beyond being an extremely useful tool for organizing your daily routine, this project lets you understand essential fundamentals such as time manipulation, control loops, and external libraries. Imagine never forgetting to drink water or missing an important meeting because you built the technological solution yourself. This guide walks through the step-by-step process for developing your own intelligent alarm clock using Python.

Why build an alarm reminder system in Python?

Building small utilities is the best way to consolidate theoretical knowledge. When you decide to create a reminder system, you stop just reading about syntax and start applying Python programming logic in practice. This project addresses concepts that are pillars of software development, such as waiting for specific events and interacting with the operating system to emit sounds or notifications.

Python is also the ideal language for quick automations. With very few lines of code, you can integrate functionalities that other languages would require hundreds of lines to achieve. Mastering this script builds confidence to advance into more complex topics, such as graphical interfaces with Tkinter or API integrations.

Setting up the development environment

Before writing any code, make sure your computer has everything needed. The first step is having the interpreter installed. If you have not done that yet, check the guide on how to install Python to prepare your machine correctly.

For this project, the native libraries time and datetime are used. For audio, winsound (Windows-only) or playsound (cross-platform) are the most common choices. VS Code is the recommended editor, and you can boost productivity with the best VS Code extensions for Python.

Installing external dependencies

Bash
pip install playsound==1.2.2

Version 1.2.2 of playsound is the most stable across different operating systems, avoiding common compatibility issues with file paths.

Step 1: Capturing user input

The first logical step is asking the user when the alarm should fire. You need to collect the hour and minute precisely. The Python input function handles that. Validating that the user entered valid numbers is essential to prevent the program from crashing.

Python
alarm_hour = input("Enter the alarm hour (HH): ")
alarm_minute = input("Enter the alarm minute (MM): ")
message = input("What is the name of this reminder? ")

print(f"Alarm set for {alarm_hour}:{alarm_minute}. Reminder: {message}")

At this stage, the values are stored as strings in Python variables. They will need to be converted to integers later for the time comparisons in the main loop.

Step 2: Managing time with the datetime module

For the system to know when to fire, it must continuously consult the system clock. Python has a powerful module called datetime for handling dates and times in Python. The key is creating a loop that checks the current time and compares it to the time the user defined.

Python
import datetime
import time

while True:
    now = datetime.datetime.now()
    if now.hour == int(alarm_hour) and now.minute == int(alarm_minute):
        print("BEEP! BEEP! REMINDER TIME!")
        break
    time.sleep(10)  # Check every 10 seconds to save CPU

Using time.sleep(10) is a recommended practice to prevent your script from consuming 100% CPU by running a check thousands of times per second unnecessarily.

Step 3: Adding the sound alarm

A visual reminder is good, but a sound alarm is far more effective. On Windows, you can use the system’s built-in function to emit a beep at a specific frequency, but the ideal approach is playing a pleasant MP3 or WAV file. Make sure you have an audio file named alarm.mp3 in the same folder as your script to avoid a FileNotFoundError in Python.

Python
from playsound import playsound

# Inside the alarm condition:
print(f"ATTENTION: {message}")
playsound('alarm.mp3')

Step 4: Input validation with try-except

What if the user types “abc” instead of a number, or enters “25” for the hour? Using try-except in Python is mandatory here to make the system professional and resilient.

Python
try:
    alarm_hour = int(input("Hour (0-23): "))
    alarm_minute = int(input("Minute (0-59): "))
    if not (0 <= alarm_hour <= 23 and 0 <= alarm_minute <= 59):
        raise ValueError("Invalid hour or minute!")
except ValueError as e:
    print(f"Configuration error: {e}")
    exit()

Complete project script

Below is the unified, robust script that integrates data capture, validation, the time-checking loop, and the sound alert. Make sure you have playsound==1.2.2 installed and an alarm.mp3 file in the same directory before running it.

Python
import datetime
import time
from playsound import playsound

def configure_alarm():
    print("--- PYTHON REMINDER SYSTEM ---")
    try:
        h = int(input("Enter the desired HOUR (0-23): "))
        m = int(input("Enter the desired MINUTE (0-59): "))
        msg = input("Enter the reminder message: ")

        if not (0 <= h <= 23 and 0 <= m <= 59):
            print("Invalid time! Use numbers between 0-23 for hours and 0-59 for minutes.")
            return None

        return {"hour": h, "minute": m, "message": msg}
    except ValueError:
        print("Invalid input! Enter only numbers for the time.")
        return None

def start_system():
    alarm = configure_alarm()
    if not alarm:
        return

    print(f"nAlarm activated for {alarm['hour']:02d}:{alarm['minute']:02d}.")
    print("The program will keep running in the background...")

    while True:
        now = datetime.datetime.now()

        if now.hour == alarm['hour'] and now.minute == alarm['minute']:
            print(f"n[ALERT FIRED]: {alarm['message']}")
            try:
                # Make sure 'alarm.mp3' is in the same directory
                playsound('alarm.mp3')
            except Exception as e:
                print(f"Could not play sound: {e}")
                print("a")  # Fallback system beep

            print("Reminder complete. Shutting down.")
            break

        # Sleep 30 seconds to avoid overloading the processor
        time.sleep(30)

if __name__ == "__main__":
    start_system()

Expanding your reminder system

Now that the core system works, there are several paths to make it more powerful. You can add a visual interface using Tkinter graphical interfaces, allowing users who do not know programming to use your tool. Another useful upgrade is saving reminders to a file or database so they persist between sessions — see how to integrate Python with SQLite for that. For detailed technical references on time handling, the official Python datetime documentation and the playsound PyPI page are excellent starting points.

Frequently Asked Questions

Does the script need to stay open for the alarm to fire?

Yes. Since it is a terminal script running in a while loop, the process must remain active in memory to monitor the clock.

Can I set more than one alarm?

Not in this simplified version, but you can modify the code to use a list of dictionaries and iterate over it inside the main loop.

The sound did not play. What could be wrong?

The most common cause is a file path issue. Verify that the audio file is in the same folder as the .py file and that the name matches exactly in the code.

How do I make the alarm keep ringing until I stop it?

Place the playsound call inside a while True loop, but you will need to implement a way to interrupt it, such as a keyboard input.

Will time.sleep(30) cause the alarm to fire late?

Since the check only compares hour and minute, 30 seconds is a safe interval. The alarm will fire within the correct minute. If you needed second-level precision, sleep should be set to 1 second.

How do I convert this script into an executable?

Use PyInstaller to transform your .py file into a .exe for Windows or a .app for Mac.

Is there a way to silence the alarm via code?

For volume control or stopping audio before the file ends, more robust libraries like pygame.mixer are recommended over playsound.

Share:

Facebook
WhatsApp
Twitter
LinkedIn

Article content

    Related articles

    Calendário mensal gerado automaticamente com Python
    Projects
    Foto de perfil de Leandro Hirt da Academify

    Generate a Monthly Calendar in Python in 2 Minutes

    Generate a monthly calendar in Python in 2 minutes using the built-in calendar module, with user input, Sunday start, file

    Ler mais

    Tempo de leitura: 4 minutos
    29/05/2026
    Sistema de login simples desenvolvido com Python
    Projects
    Foto de perfil de Leandro Hirt da Academify

    Simple Python Login System with TXT Files

    Learn how to build a simple Python login system using TXT files, with user registration, password validation, error handling, and

    Ler mais

    Tempo de leitura: 5 minutos
    29/05/2026
    Sistema de tradução automática desenvolvido com Python
    Projects
    Foto de perfil de Leandro Hirt da Academify

    Build an Automatic Translation System in Python

    Learn how to build an automatic translation system in Python using Googletrans, with language detection, batch translation, error handling, and

    Ler mais

    Tempo de leitura: 5 minutos
    28/05/2026
    Landing page simples criada com Python e Tailwind CSS
    Projects
    Foto de perfil de Leandro Hirt da Academify

    Build a Python Landing Page with Tailwind CSS

    Learn how to build a modern landing page with Python, Flask, Tailwind CSS, responsive design, forms, project structure, and deployment

    Ler mais

    Tempo de leitura: 8 minutos
    19/05/2026
    Conversão de áudio para texto usando Python gratuitamente
    Projects
    Foto de perfil de Leandro Hirt da Academify

    How to Convert Audio to Text with Python for Free

    Learn how to convert audio to text with Python for free using SpeechRecognition and Whisper. This guide covers WAV and

    Ler mais

    Tempo de leitura: 9 minutos
    12/05/2026
    Extração de dados de tabelas de sites usando Python e pandas
    Projects
    Foto de perfil de Leandro Hirt da Academify

    Extract Web Tables with Python & Pandas

    Learn how to extract table data from websites with Python and Pandas using read_html. This guide covers setup, data cleaning,

    Ler mais

    Tempo de leitura: 10 minutos
    11/05/2026