Help, my raspberry pi that I'm using for an alarm clock isn't going off

The Raspberry Pi is a series of credit card-sized single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote the teaching of basic computer science in schools and developing countries.

Post Reply
User avatar
/RaspberryPi
Corporate
Posts: 2449
Joined: Wed Jun 05, 2019 1:29 am

Help, my raspberry pi that I'm using for an alarm clock isn't going off

Post by /RaspberryPi »

It'll go off when I test it, but when I leave it on from ssh on my computer it won't go off when it's supposed to
```
from pygame import mixer
from datetime import datetime
import os
from time import sleep

mixer.init()
os.chdir('/home/pi')

blacklist = ['Friday', 'Saturday', 'Sunday']
test = input('is this a test run?\n')
alarm = True

def playAlarm():
print('playing alarm')
for i in range(2):
mixer.music.load('man-screaming.mp3')
mixer.music.play()
while mixer.music.get_busy():
sleep(.5)
print(datetime.now())

main = True
while main:
day = datetime.now().strftime('%A')
time = datetime.now()

print('checking blacklist...')
for i in blacklist:
if day == i:
alarm = False
print('alarm will not go off today')
else:
alarm = True
print('alarm will go off today')
if alarm and str(time.hour) == '7' and str(time.minute) == '05' or test == 'yes' or test == 'y':
playAlarm()

sleep(2)
test = ''
```

submitted by /u/derpykidgamer
[link] [comments]

More...
Post Reply

Return to “Raspberry Pi Forum”