As I said in my other post you can us cron to call both the python and aplay commands.
So one way to do this would be to create a python program that turns on your amp using the code you already have then simply waits for a set time before turning it off.
some thing like this
Code: Select all
import pifacedigitalio
import time
# so we wait 30 seconds before switching amp on
time.sleep(30)
# now switch amp on
pfd = pifacedigitalio.PiFaceDigital()
pfd.output_pins[0].value = 1 (Swich the relay on)
# now wait 90 seconds
time.sleep(90)
# now turn amp off
pfd.output_pins[0].value = 0
the first delay is because we are going to call this 1 min before you want to play the sound to allow the amp to power up. all values can be changed if need be
now all you need is to call the python program and the aplay command using cron.
like this
Code: Select all
59 9 * * 1-5 python3 /home/pi/amp.py
0 10 * * 1-5 aplay /home/pi/theme1.wav
so for the10am alarm we have 2 entries the first at 9:59 turns on the amp the second plays the wav file , now you must use full paths for your files in cron so to keep it simple I assumed both the wav files and the python file ( which I called amp.py ) were in the /home/pi directory which is the default pi user directory.
for ref.
https://thepihut.com/blogs/raspberry-pi ... larly-cron
https://crontab-generator.org/