Last active 1739982656

alarm.py Raw
1from datetime import datetime
2from playsound import playsound
3alarm_time = input("Enter the time of alarm to be set:HH:MM:SS\n")
4alarm_hour=alarm_time[0:2]
5alarm_minute=alarm_time[3:5]
6alarm_seconds=alarm_time[6:8]
7alarm_period = alarm_time[9:11].upper()
8print("Setting up alarm..")
9while True:
10 now = datetime.now()
11 current_hour = now.strftime("%I")
12 current_minute = now.strftime("%M")
13 current_seconds = now.strftime("%S")
14 current_period = now.strftime("%p")
15 if(alarm_period==current_period):
16 if(alarm_hour==current_hour):
17 if(alarm_minute==current_minute):
18 if(alarm_seconds==current_seconds):
19 print("Wake Up!")
20 playsound('audio.mp3')
21 break