-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalarm-clock
More file actions
30 lines (22 loc) · 764 Bytes
/
alarm-clock
File metadata and controls
30 lines (22 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import time
import datetime
import pygame
def set_alarm(alarm_time):
print(f"alarm set for {alarm_time}")
sound_file = "C:/Users/mhurs/Desktop/python/project_medium/sound_file.mp3"
is_running = True
while is_running:
current_time = datetime.datetime.now().strftime("%H:%M:%S")
print(current_time)
if current_time == alarm_time:
print("wake up")
pygame.mixer.init()
pygame.mixer.music.load(sound_file)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
time.sleep(1)
is_running = False
time.sleep(1)
if __name__ == "__main__":
alarm_time = input("emter alarm time (HH:MM:SS): ")
set_alarm(alarm_time)