← Projects

Alarm clock done

f1cfaec5073ce4cb06eafa5d5540e5030bc66c46 · Karan Goel · Jul 13, 2013 13:53

Right now it beeps, need to add ability to play a sound.

+22 · 1 file changed

  • Numbers/alarm.py +22 −0
diff --git a/Numbers/alarm.py b/Numbers/alarm.py
new file mode 100644
index 0000000..b80f108
--- /dev/null
+++ b/Numbers/alarm.py
@@ -0,0 +1,22 @@
+"""
+Alarm Clock - A simple clock where it plays a sound after
+X number of minutes/seconds or at a particular time.
+"""
+
+import time
+import winsound
+
+if __name__ == '__main__':
+    hh = input('What hour do you want to wake up (0-23)? ')
+    mm = input('What minute do you want to wake up (0-59)? ')
+
+    not_alarmed = 1
+
+    while(not_alarmed):
+        cur_time = list(time.localtime()) # get the time right now
+        hour = cur_time[3] # find the hour
+        minute = cur_time[4] # and the minute
+        if hour == hh and minute == mm:
+            winsound.Beep(10000, 100) # play the beep
+            not_alarmed = 0 # stop the loop
+