Alarm Clock
I am building a Alarm Clock Radio. One of its features is to be able to set an alarm and play music when the alarm goes off.
I should know what features are required for an alarm clock, but writing a script and playing with it for a while gives me a better understanding of what I need. So, I wrote a python script to set alarms in crontab and play songs when the alarm time was reached. I diddled with this for a while until it seemed to do everything I wanted. Eventually, I will add the commands in the python script to the Alarm Clock GUI.
Parts:
Raspberry Pi 3
HiBerry AMP2
1 or 2 Speakers
Step 1. Set up Song Player
Step 2. Install python-crontab
$ sudo pip3 install python-crontab
Step 3. Add the python 3 script to Raspberry Pi
cd to the /home/pi/radio directory and run the command:
$ sudo wget "https://raw.githubusercontent.com/dumbo25/alarm/master/alarm.py"
Run the script using:
$ python3 alarm.py
Common commands:
Copy file from Raspberry Pi 3 to laptop. Open a terminal window on MacBook laptop. Navigate to whatever directory you want to use as backup for the script and run the command:
$ scp pi@♣hostname♣.local:/home/pi/radio/alarm.py .
References:
EnvatoTuts+: Managing cron jobs using python
PyPi: python crontab