From aa0881f31351a3089f8a02abd63e789acb506df7 Mon Sep 17 00:00:00 2001 From: MOHAMMED SHAHEER V K <91910806+Outlooker007@users.noreply.github.com> Date: Sat, 25 Oct 2025 10:55:56 +0530 Subject: [PATCH] Create ALARM CLOCK SIMPLE.PY --- Alarm-Clock/ALARM CLOCK SIMPLE.PY | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Alarm-Clock/ALARM CLOCK SIMPLE.PY diff --git a/Alarm-Clock/ALARM CLOCK SIMPLE.PY b/Alarm-Clock/ALARM CLOCK SIMPLE.PY new file mode 100644 index 00000000..fc887f6d --- /dev/null +++ b/Alarm-Clock/ALARM CLOCK SIMPLE.PY @@ -0,0 +1,27 @@ +import time +import datetime +import winsound # For Windows sound playback; on Linux/Mac, use other libraries like playsound + +# Function to play alarm sound +def play_alarm(): + frequency = 2500 # Set Frequency in Hertz + duration = 1000 # Set Duration in milliseconds + winsound.Beep(frequency, duration) + +# Function to set the alarm +def set_alarm(alarm_time): + print(f"Alarm is set for {alarm_time}") + while True: + # Get current time in HH:MM format + current_time = datetime.datetime.now().strftime("%H:%M") + if current_time == alarm_time: + print("Wake up! Alarm ringing!") + play_alarm() + break + time.sleep(10) # Sleep 10 seconds before checking again + +# Example usage +if __name__ == "__main__": + # User sets alarm time in HH:MM 24-hour format + alarm_time_input = input("Enter alarm time (HH:MM): ") + set_alarm(alarm_time_input)