Skip to content

1N-i/Alarm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

14 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โฐ Python Alarm Clock

Python Library

A countdown timer and alarm that uses ANSI escape codes for dynamic screen updates and plays an audio alert when time is up.

๐Ÿ“‹ Summary


๐Ÿ›  Technologies

  • Python 3.x: Core logic and timing.
  • Playsound3: For audio playback functionality.
  • Time Module: Handles the countdown intervals and delays.

โœจ Features

  • Dynamic UI: Uses ANSI escape codes (\035[2J and \035[H) to clear the terminal and refresh the timer in place, providing a clean interface.
  • Precise Calculation: Converts raw seconds into a formatted MM:SS display using integer division and modulo operators.
  • Audio Notification: Triggers an external .mp3 file once the countdown reaches zero.

๐Ÿ“‚ Project Architecture

  • alarm.py: The main script containing the timing loop, screen clearing logic, and audio trigger.
  • alarm.mp3: The audio file used for the alarm sound.

๐Ÿ“š What I Learned

  • Terminal Control: How to use ANSI codes to manipulate the console cursor and clear the screen without spamming new lines.
  • Time Formatting: Using floor division (//) and modulo (%) to transform total seconds into readable time units.
  • External Libraries: Integrating playsound3 to handle cross-platform audio execution.

๐Ÿ”ฎ Future Improvements

  • User input for custom alarm durations.
  • Support for multiple alarm sounds/choices.
  • A graphical progress bar.

๐Ÿš€ How to Run

  1. Install dependencies: This project requires the playsound3 library:
    pip install playsound3

Releases

No releases published

Packages

 
 
 

Contributors

Languages