pwm connected to the speaker to tell the hour [keyestudio's 8002 module]

Although it is very convenient to check the time now, it seems that my sense of time is getting worse and worse. So I decided to tell the time on the hour, reminding myself that time flies, don't always be blind.

 This article mainly talks about the assembly method and configuration, and that’s about it. No code involved. For 3-pin components, remove the positive and negative wiring (this one is connected to 5V), there is only signal, and find a pwm pin. I looked at /boot/overlays/README and found that pwm1 is the pin of gpio18, which is a popular product, so I connected it. Next, let’s take a look at my /boot/config.txt. In addition to a search, I also learned how to configure it through the README. So this file is something to count instead.

# Enable audio (loads snd_bcm2835)
#dtparam=audio=on
audio_pwm_mode=2

[all]
dtoverlay=pwm
dtoverlay=audremap,pins_18

Tell time bash on time.

#!/bin/bash
#
# call out the hour. run in crontab

HOUR=`date "+%k"`
FIRST=9
LAST=23
SPEAK="/usr/bin/espeak-ng"
#SPEAK="aoss espeak" #for multiple access to soundcard

#shh! its night time
[ $HOUR -lt $FIRST ] || [ $HOUR -gt $LAST ] && exit 1

#english
echo "Its $HOUR oclock" | $SPEAK

crontab: Use 'which bash' to determine the bash path.

0 * * * * /usr/bin/bash /home/bash/o_clock.sh

Guess you like

Origin blog.csdn.net/u011410413/article/details/132295105